Repository: commons-lang Updated Branches: refs/heads/master 52b46e74d -> 958029bdd
LANG-1002 Several predefined ISO FastDateFormats in DateFormatUtils are incorrect Project: http://git-wip-us.apache.org/repos/asf/commons-lang/repo Commit: http://git-wip-us.apache.org/repos/asf/commons-lang/commit/958029bd Tree: http://git-wip-us.apache.org/repos/asf/commons-lang/tree/958029bd Diff: http://git-wip-us.apache.org/repos/asf/commons-lang/diff/958029bd Branch: refs/heads/master Commit: 958029bdd45c3e341eb146031ed38b4487d7b0b7 Parents: 52b46e7 Author: Chas Honton <c...@apache.org> Authored: Tue Jul 7 22:50:53 2015 -0700 Committer: Chas Honton <c...@apache.org> Committed: Tue Jul 7 22:50:53 2015 -0700 ---------------------------------------------------------------------- src/changes/changes.xml | 1 + .../commons/lang3/time/DateFormatUtils.java | 67 ++++++++++++++++---- 2 files changed, 55 insertions(+), 13 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/commons-lang/blob/958029bd/src/changes/changes.xml ---------------------------------------------------------------------- diff --git a/src/changes/changes.xml b/src/changes/changes.xml index 83bf55a..19e7c11 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -22,6 +22,7 @@ <body> <release version="3.5" date="tba" description="tba"> + <action issue="LANG-1002" type="fix" dev="chas" due-to="Michael Osipov">Several predefined ISO FastDateFormats in DateFormatUtils are incorrect</action> <action issue="LANG-1152" type="fix" dev="chas" due-to="Pas Filip">StringIndexOutOfBoundsException or field over-write for large year fields in FastDateParser</action> <action issue="LANG-1153" type="add" dev="chas">Implement ParsePosition api for FastDateParser</action> <action issue="LANG-1141" type="fix" dev="oheger">StrLookup.systemPropertiesLookup() no longer reacts on changes on system properties</action> http://git-wip-us.apache.org/repos/asf/commons-lang/blob/958029bd/src/main/java/org/apache/commons/lang3/time/DateFormatUtils.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/lang3/time/DateFormatUtils.java b/src/main/java/org/apache/commons/lang3/time/DateFormatUtils.java index 642eb4d..88640b4 100644 --- a/src/main/java/org/apache/commons/lang3/time/DateFormatUtils.java +++ b/src/main/java/org/apache/commons/lang3/time/DateFormatUtils.java @@ -39,77 +39,118 @@ public class DateFormatUtils { * This is private as it is mutable. */ private static final TimeZone UTC_TIME_ZONE = TimeZone.getTimeZone("GMT"); + /** * ISO 8601 formatter for date-time without time zone. * The format used is {@code yyyy-MM-dd'T'HH:mm:ss}. * This format uses the default TimeZone in effect at the time of loading DateFormatUtils class. + * @since 3.5 */ - public static final FastDateFormat ISO_DATETIME_FORMAT + public static final FastDateFormat ISO8601_DATETIME_FORMAT = FastDateFormat.getInstance("yyyy-MM-dd'T'HH:mm:ss"); /** + * @deprecated - as of 4.0, ISO_DATETIME_FORMAT will be replaced by ISO8601_DATETIME_FORMAT. + */ + @Deprecated + public static final FastDateFormat ISO_DATETIME_FORMAT = ISO8601_DATETIME_FORMAT; + + /** * ISO 8601 formatter for date-time with time zone. * The format used is {@code yyyy-MM-dd'T'HH:mm:ssZZ}. * This format uses the default TimeZone in effect at the time of loading DateFormatUtils class. + * @since 3.5 */ - public static final FastDateFormat ISO_DATETIME_TIME_ZONE_FORMAT + public static final FastDateFormat ISO8601_DATETIME_TIME_ZONE_FORMAT = FastDateFormat.getInstance("yyyy-MM-dd'T'HH:mm:ssZZ"); /** + * @deprecated - as of 4.0, ISO_DATETIME_TIME_ZONE_FORMAT will be replaced by ISO8601_DATETIME_TIME_ZONE_FORMAT. + */ + @Deprecated + public static final FastDateFormat ISO_DATETIME_TIME_ZONE_FORMAT = ISO8601_DATETIME_TIME_ZONE_FORMAT; + + /** * ISO 8601 formatter for date without time zone. * The format used is {@code yyyy-MM-dd}. * This format uses the default TimeZone in effect at the time of loading DateFormatUtils class. + * @since 3.5 */ - public static final FastDateFormat ISO_DATE_FORMAT + public static final FastDateFormat ISO8601_DATE_FORMAT = FastDateFormat.getInstance("yyyy-MM-dd"); /** + * @deprecated - as of 4.0, ISO_DATE_FORMAT will be replaced by ISO8601_DATE_FORMAT. + */ + @Deprecated + public static final FastDateFormat ISO_DATE_FORMAT = ISO8601_DATE_FORMAT; + + /** * ISO 8601-like formatter for date with time zone. * The format used is {@code yyyy-MM-ddZZ}. * This pattern does not comply with the formal ISO 8601 specification * as the standard does not allow a time zone without a time. * This format uses the default TimeZone in effect at the time of loading DateFormatUtils class. + * + * @deprecated - as of 4.0, ISO_DATE_TIME_ZONE_FORMAT will be removed. */ + @Deprecated public static final FastDateFormat ISO_DATE_TIME_ZONE_FORMAT = FastDateFormat.getInstance("yyyy-MM-ddZZ"); /** - * ISO 8601 formatter for time without time zone. + * Non-compliant formatter for time without time zone. (ISO 8601 does not prefix 'T' for standalone time value) * The format used is {@code 'T'HH:mm:ss}. * This format uses the default TimeZone in effect at the time of loading DateFormatUtils class. + * + * @deprecated - as of 4.0, ISO_TIME_FORMAT will be removed. */ + @Deprecated public static final FastDateFormat ISO_TIME_FORMAT = FastDateFormat.getInstance("'T'HH:mm:ss"); /** - * ISO 8601 formatter for time with time zone. + * Non-compliant formatter for time with time zone. (ISO 8601 does not prefix 'T' for standalone time value) * The format used is {@code 'T'HH:mm:ssZZ}. * This format uses the default TimeZone in effect at the time of loading DateFormatUtils class. + * + * @deprecated - as of 4.0, ISO_TIME_TIME_ZONE_FORMAT will be removed. */ + @Deprecated public static final FastDateFormat ISO_TIME_TIME_ZONE_FORMAT = FastDateFormat.getInstance("'T'HH:mm:ssZZ"); /** - * ISO 8601-like formatter for time without time zone. + * ISO 8601 formatter for time without time zone. * The format used is {@code HH:mm:ss}. - * This pattern does not comply with the formal ISO 8601 specification - * as the standard requires the 'T' prefix for times. * This format uses the default TimeZone in effect at the time of loading DateFormatUtils class. + * @since 3.5 */ - public static final FastDateFormat ISO_TIME_NO_T_FORMAT + public static final FastDateFormat ISO8601_TIME_FORMAT = FastDateFormat.getInstance("HH:mm:ss"); /** - * ISO 8601-like formatter for time with time zone. + * @deprecated - as of 4.0, ISO_TIME_NO_T_FORMAT will be replaced by ISO8601_TIME_FORMAT. + */ + @Deprecated + public static final FastDateFormat ISO_TIME_NO_T_FORMAT = ISO8601_TIME_FORMAT; + + /** + * ISO 8601 formatter for time with time zone. * The format used is {@code HH:mm:ssZZ}. - * This pattern does not comply with the formal ISO 8601 specification - * as the standard requires the 'T' prefix for times. * This format uses the default TimeZone in effect at the time of loading DateFormatUtils class. + * @since 3.5 */ - public static final FastDateFormat ISO_TIME_NO_T_TIME_ZONE_FORMAT + public static final FastDateFormat ISO8601_TIME_TIME_ZONE_FORMAT = FastDateFormat.getInstance("HH:mm:ssZZ"); /** + * @deprecated - as of 4.0, ISO_TIME_NO_T_TIME_ZONE_FORMAT will be replaced by ISO8601_TIME_TIME_ZONE_FORMAT. + */ + @Deprecated + public static final FastDateFormat ISO_TIME_NO_T_TIME_ZONE_FORMAT = ISO8601_TIME_TIME_ZONE_FORMAT; + + /** * SMTP (and probably other) date headers. * The format used is {@code EEE, dd MMM yyyy HH:mm:ss Z} in US locale. * This format uses the default TimeZone in effect at the time of loading DateFormatUtils class.