You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by br...@apache.org on 2014/01/05 13:08:30 UTC
svn commit: r1555485 - in /commons/proper/lang/trunk/src: changes/changes.xml
main/java/org/apache/commons/lang3/time/FastDateParser.java
Author: britter
Date: Sun Jan 5 12:08:29 2014
New Revision: 1555485
URL: http://svn.apache.org/r1555485
Log:
LANG-942: Test failure in FastDateParserTest and FastDateFormat_ParserTest when building with JDK8. Thanks to Bruno P. Kinoshita and Henri Yandell for their help in fixing this issue.
Modified:
commons/proper/lang/trunk/src/changes/changes.xml
commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/time/FastDateParser.java
Modified: commons/proper/lang/trunk/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/changes/changes.xml?rev=1555485&r1=1555484&r2=1555485&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/changes/changes.xml [utf-8] (original)
+++ commons/proper/lang/trunk/src/changes/changes.xml [utf-8] Sun Jan 5 12:08:29 2014
@@ -24,6 +24,7 @@
<release version="3.2.1" date="TBA" description="Bug fix for 3.2">
<action issue="LANG-937" type="fix" dev="britter">Fix missing Hamcrest dependency in Ant Build</action>
<action issue="LANG-941" type="fix" dev="britter">Test failure in LocaleUtilsTest when building with JDK 8</action>
+ <action issue="LANG-942" type="fix" dev="britter" due-to="Bruno P. Kinoshita, Henri Yandell">Test failure in FastDateParserTest and FastDateFormat_ParserTest when building with JDK8</action>
</release>
<release version="3.2" date="2014-01-01" description="Bug fixes and new features, at least requires Java 6.0">
Modified: commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/time/FastDateParser.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/time/FastDateParser.java?rev=1555485&r1=1555484&r2=1555485&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/time/FastDateParser.java (original)
+++ commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/time/FastDateParser.java Sun Jan 5 12:08:29 2014
@@ -19,6 +19,7 @@ package org.apache.commons.lang3.time;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.Serializable;
+import java.text.DateFormatSymbols;
import java.text.ParseException;
import java.text.ParsePosition;
import java.util.ArrayList;
@@ -680,22 +681,53 @@ public class FastDateParser implements D
private final SortedMap<String, TimeZone> tzNames= new TreeMap<String, TimeZone>(String.CASE_INSENSITIVE_ORDER);
/**
+ * Index of zone id
+ */
+ private static final int ID = 0;
+ /**
+ * Index of the long name of zone in standard time
+ */
+ private static final int LONG_STD = 1;
+ /**
+ * Index of the short name of zone in standard time
+ */
+ private static final int SHORT_STD = 2;
+ /**
+ * Index of the long name of zone in daylight saving time
+ */
+ private static final int LONG_DST = 3;
+ /**
+ * Index of the short name of zone in daylight saving time
+ */
+ private static final int SHORT_DST = 4;
+
+ /**
* Construct a Strategy that parses a TimeZone
* @param locale The Locale
*/
TimeZoneStrategy(final Locale locale) {
- for(final String id : TimeZone.getAvailableIDs()) {
- if(id.startsWith("GMT")) {
+ final String[][] zones = DateFormatSymbols.getInstance(locale).getZoneStrings();
+ for (String[] zone : zones) {
+ if (zone[ID].startsWith("GMT")) {
continue;
}
- final TimeZone tz= TimeZone.getTimeZone(id);
- tzNames.put(tz.getDisplayName(false, TimeZone.SHORT, locale), tz);
- tzNames.put(tz.getDisplayName(false, TimeZone.LONG, locale), tz);
- if(tz.useDaylightTime()) {
- tzNames.put(tz.getDisplayName(true, TimeZone.SHORT, locale), tz);
- tzNames.put(tz.getDisplayName(true, TimeZone.LONG, locale), tz);
+ final TimeZone tz = TimeZone.getTimeZone(zone[ID]);
+ if (!tzNames.containsKey(zone[LONG_STD])){
+ tzNames.put(zone[LONG_STD], tz);
+ }
+ if (!tzNames.containsKey(zone[SHORT_STD])){
+ tzNames.put(zone[SHORT_STD], tz);
+ }
+ if (tz.useDaylightTime()) {
+ if (!tzNames.containsKey(zone[LONG_DST])){
+ tzNames.put(zone[LONG_DST], tz);
+ }
+ if (!tzNames.containsKey(zone[SHORT_DST])){
+ tzNames.put(zone[SHORT_DST], tz);
+ }
}
}
+
final StringBuilder sb= new StringBuilder();
sb.append("(GMT[+\\-]\\d{0,1}\\d{2}|[+\\-]\\d{2}:?\\d{2}|");
for(final String id : tzNames.keySet()) {