unit test to show FastDateParser has same behavior as SimpleDateFormat when dealing with greater than two digit days values

This commit is contained in:
Chas Honton 2015-04-30 09:11:21 -07:00
parent f431270c59
commit cb83f7cb31
1 changed files with 28 additions and 0 deletions

View File

@ -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);
}
}