60315 -- allow 'yyyy-MM-dd' as a valid date format in metadata in OPCParser

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1767026 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Tim Allison 2016-10-28 14:11:52 +00:00
parent ca8d888f83
commit 1cdf883548
2 changed files with 5 additions and 1 deletions

View File

@ -55,6 +55,7 @@ public final class PackagePropertiesPart extends PackagePart implements
private final static String[] DATE_FORMATS = new String[]{
DEFAULT_DATEFORMAT,
"yyyy-MM-dd'T'HH:mm:ss.SS'Z'",
"yyyy-MM-dd"
};
//Had to add this and TIME_ZONE_PAT to handle tz with colons.
@ -635,7 +636,7 @@ public final class PackagePropertiesPart extends PackagePart implements
if (date == null) {
return "";
}
SimpleDateFormat df = new SimpleDateFormat(DEFAULT_DATEFORMAT, Locale.ROOT);
df.setTimeZone(LocaleUtil.TIMEZONE_UTC);
return df.format(date);

View File

@ -94,6 +94,9 @@ public final class TestPackageCoreProperties {
props.setCreatedProperty("2007-05-12T06:00:00-0200");
assertEquals(dateToInsert, props.getCreatedProperty().getValue());
props.setCreatedProperty("2015-07-27");
assertEquals(msdf.parse("2015-07-27T00:00:00.000Z"), props.getCreatedProperty().getValue());
props.setCreatedProperty("2007-05-12T10:00:00.123+0200");
assertEquals(msdf.parse("2007-05-12T08:00:00.123Z"), props.getCreatedProperty().getValue());