From cb83f7cb31e50f265e098c5380b3f0051e257f46 Mon Sep 17 00:00:00 2001 From: Chas Honton Date: Thu, 30 Apr 2015 09:11:21 -0700 Subject: [PATCH] unit test to show FastDateParser has same behavior as SimpleDateFormat when dealing with greater than two digit days values --- .../lang3/time/FastDateParserTest.java | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) 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 3651eae0b..1d8643755 100644 --- a/src/test/java/org/apache/commons/lang3/time/FastDateParserTest.java +++ b/src/test/java/org/apache/commons/lang3/time/FastDateParserTest.java @@ -639,4 +639,32 @@ public class FastDateParserTest { assertEquals(message+trial.three, cal.getTime(), parser.parse(dateStub+trial.three)); } } + + @Test + public void testLang1121() throws ParseException { + TimeZone kst = TimeZone.getTimeZone("KST"); + final DateParser fdp = FastDateFormat.getInstance("yyyyMMdd", kst, Locale.KOREA); + + try { + fdp.parse("2015"); + Assert.fail("expected parse exception"); + } catch (ParseException pe) { + } + + // Wed Apr 29 00:00:00 KST 2015 + Date actual = fdp.parse("20150429"); + final Calendar cal = Calendar.getInstance(kst, Locale.KOREA); + cal.clear(); + cal.set(2015, 3, 29); + Date expected = cal.getTime(); + Assert.assertEquals(expected, actual); + + SimpleDateFormat df = new SimpleDateFormat("yyyyMMdd", Locale.KOREA); + df.setTimeZone(kst); + expected = df.parse("20150429113100"); + + // Thu Mar 16 00:00:00 KST 81724 + actual = fdp.parse("20150429113100"); + Assert.assertEquals(expected, actual); + } }