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 79fb7c605..d5a5be27b 100644 --- a/src/main/java/org/apache/commons/lang3/time/FastDateParser.java +++ b/src/main/java/org/apache/commons/lang3/time/FastDateParser.java @@ -25,6 +25,7 @@ import java.text.ParsePosition; import java.util.ArrayList; import java.util.Calendar; import java.util.Date; +import java.util.HashMap; import java.util.List; import java.util.Locale; import java.util.Map; @@ -586,6 +587,7 @@ public class FastDateParser implements DateParser, Serializable { private static class TextStrategy extends Strategy { private final int field; private final Map keyValues; + private final Map lKeyValues; /** * Construct a Strategy that parses a Text field @@ -596,6 +598,11 @@ public class FastDateParser implements DateParser, Serializable { TextStrategy(final int field, final Calendar definingCalendar, final Locale locale) { this.field= field; this.keyValues= getDisplayNames(field, definingCalendar, locale); + this.lKeyValues= new HashMap(); + + for(Map.Entry entry : keyValues.entrySet()) { + lKeyValues.put(entry.getKey().toLowerCase(), entry.getValue()); + } } /** @@ -603,7 +610,7 @@ public class FastDateParser implements DateParser, Serializable { */ @Override boolean addRegex(final FastDateParser parser, final StringBuilder regex) { - regex.append('('); + regex.append("((?i)(?u)"); for(final String textKeyValue : keyValues.keySet()) { escapeRegex(regex, textKeyValue, false).append('|'); } @@ -616,7 +623,7 @@ public class FastDateParser implements DateParser, Serializable { */ @Override void setCalendar(final FastDateParser parser, final Calendar cal, final String value) { - final Integer iVal = keyValues.get(value); + final Integer iVal = lKeyValues.get(value.toLowerCase()); if(iVal == null) { final StringBuilder sb= new StringBuilder(value); sb.append(" not in ("); diff --git a/src/test/java/org/apache/commons/lang3/time/FastDateParserTest.java b/src/test/java/org/apache/commons/lang3/time/FastDateParserTest.java index b3dcb093c..a90deb629 100644 --- a/src/test/java/org/apache/commons/lang3/time/FastDateParserTest.java +++ b/src/test/java/org/apache/commons/lang3/time/FastDateParserTest.java @@ -540,4 +540,16 @@ public class FastDateParserTest { final DateParser parser= getInstance(yMdHmsSZ, REYKJAVIK); assertEquals(REYKJAVIK, parser.getTimeZone()); } + + @Test + public void testLang996() throws ParseException { + Calendar expected = Calendar.getInstance(NEW_YORK, Locale.US); + expected.clear(); + expected.set(2014, 4, 14); + + final DateParser fdp = getInstance("ddMMMyyyy", NEW_YORK, Locale.US); + assertEquals(expected.getTime(), fdp.parse("14may2014")); + assertEquals(expected.getTime(), fdp.parse("14MAY2014")); + assertEquals(expected.getTime(), fdp.parse("14May2014")); + } }