diff --git a/src/changes/changes.xml b/src/changes/changes.xml index aa455333b7d..6a7a864dc24 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -22,6 +22,7 @@ + FastDateParser_TimeZoneStrategyTest#testTimeZoneStrategyPattern fails on Windows with German Locale Add method containsAllWords to WordUtils ReflectionToStringBuilder doesn't throw IllegalArgumentException when the constructor's object param is null Inconsistent behavior of swap for malformed inputs diff --git a/src/main/java/org/apache/commons/lang3/time/FastDateParser.java b/src/main/java/org/apache/commons/lang3/time/FastDateParser.java index f8a700e426d..7863322ade5 100644 --- a/src/main/java/org/apache/commons/lang3/time/FastDateParser.java +++ b/src/main/java/org/apache/commons/lang3/time/FastDateParser.java @@ -29,9 +29,7 @@ import java.util.List; import java.util.Locale; import java.util.Map; -import java.util.SortedMap; import java.util.TimeZone; -import java.util.TreeMap; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; import java.util.regex.Matcher; @@ -369,6 +367,30 @@ public Date parse(final String source, final ParsePosition pos) { // Support for strategies //----------------------------------------------------------------------- + private static StringBuilder simpleQuote(final StringBuilder sb, final String value) { + for(int i= 0; i tzNames= new TreeMap(String.CASE_INSENSITIVE_ORDER); + private final Locale locale; + private final Map tzNames= new HashMap(); + private final String validTimeZoneChars; /** * 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) { + this.locale = locale; + + final StringBuilder sb = new StringBuilder(); + sb.append('(' + RFC_822_TIME_ZONE + "|(?iu)" + GMT_OPTION ); + final String[][] zones = DateFormatSymbols.getInstance(locale).getZoneStrings(); - for (final String[] zone : zones) { - 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); + for (final String[] zoneNames : zones) { + final String tzId = zoneNames[ID]; + if (tzId.equalsIgnoreCase("GMT")) { + continue; } - 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 TimeZone tz = TimeZone.getTimeZone(tzId); + for(int i= 1; i