LANG-1002

Several predefined ISO FastDateFormats in DateFormatUtils are incorrect
This commit is contained in:
Chas Honton 2015-07-07 22:50:53 -07:00
parent 52b46e74dd
commit 958029bdd4
2 changed files with 57 additions and 15 deletions

View File

@ -22,6 +22,7 @@
<body> <body>
<release version="3.5" date="tba" description="tba"> <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-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-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> <action issue="LANG-1141" type="fix" dev="oheger">StrLookup.systemPropertiesLookup() no longer reacts on changes on system properties</action>

View File

@ -39,76 +39,117 @@ public class DateFormatUtils {
* This is private as it is mutable. * This is private as it is mutable.
*/ */
private static final TimeZone UTC_TIME_ZONE = TimeZone.getTimeZone("GMT"); private static final TimeZone UTC_TIME_ZONE = TimeZone.getTimeZone("GMT");
/** /**
* ISO 8601 formatter for date-time without time zone. * ISO 8601 formatter for date-time without time zone.
* The format used is {@code yyyy-MM-dd'T'HH:mm:ss}. * 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. * 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"); = 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. * ISO 8601 formatter for date-time with time zone.
* The format used is {@code yyyy-MM-dd'T'HH:mm:ssZZ}. * 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. * 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"); = 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. * ISO 8601 formatter for date without time zone.
* The format used is {@code yyyy-MM-dd}. * The format used is {@code yyyy-MM-dd}.
* This format uses the default TimeZone in effect at the time of loading DateFormatUtils class. * 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"); = 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. * ISO 8601-like formatter for date with time zone.
* The format used is {@code yyyy-MM-ddZZ}. * The format used is {@code yyyy-MM-ddZZ}.
* This pattern does not comply with the formal ISO 8601 specification * This pattern does not comply with the formal ISO 8601 specification
* as the standard does not allow a time zone without a time. * 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. * 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 public static final FastDateFormat ISO_DATE_TIME_ZONE_FORMAT
= FastDateFormat.getInstance("yyyy-MM-ddZZ"); = 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}. * The format used is {@code 'T'HH:mm:ss}.
* This format uses the default TimeZone in effect at the time of loading DateFormatUtils class. * 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 public static final FastDateFormat ISO_TIME_FORMAT
= FastDateFormat.getInstance("'T'HH:mm:ss"); = 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}. * The format used is {@code 'T'HH:mm:ssZZ}.
* This format uses the default TimeZone in effect at the time of loading DateFormatUtils class. * 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 public static final FastDateFormat ISO_TIME_TIME_ZONE_FORMAT
= FastDateFormat.getInstance("'T'HH:mm:ssZZ"); = 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}. * 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. * 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"); = 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.
* 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.
*/ */
public static final FastDateFormat ISO_TIME_NO_T_TIME_ZONE_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 format uses the default TimeZone in effect at the time of loading DateFormatUtils class.
* @since 3.5
*/
public static final FastDateFormat ISO8601_TIME_TIME_ZONE_FORMAT
= FastDateFormat.getInstance("HH:mm:ssZZ"); = 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. * SMTP (and probably other) date headers.
* The format used is {@code EEE, dd MMM yyyy HH:mm:ss Z} in US locale. * The format used is {@code EEE, dd MMM yyyy HH:mm:ss Z} in US locale.