You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by ch...@apache.org on 2015/04/30 18:16:18 UTC
[lang] unit test to show FastDateParser has same behavior as
SimpleDateFormat when dealing with greater than two digit days values
Repository: commons-lang
Updated Branches:
refs/heads/master f431270c5 -> cb83f7cb3
unit test to show FastDateParser has same behavior as SimpleDateFormat when dealing with greater than two digit days values
Project: http://git-wip-us.apache.org/repos/asf/commons-lang/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-lang/commit/cb83f7cb
Tree: http://git-wip-us.apache.org/repos/asf/commons-lang/tree/cb83f7cb
Diff: http://git-wip-us.apache.org/repos/asf/commons-lang/diff/cb83f7cb
Branch: refs/heads/master
Commit: cb83f7cb31e50f265e098c5380b3f0051e257f46
Parents: f431270
Author: Chas Honton <ch...@apache.org>
Authored: Thu Apr 30 09:11:21 2015 -0700
Committer: Chas Honton <ch...@apache.org>
Committed: Thu Apr 30 09:11:21 2015 -0700
----------------------------------------------------------------------
.../commons/lang3/time/FastDateParserTest.java | 28 ++++++++++++++++++++
1 file changed, 28 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-lang/blob/cb83f7cb/src/test/java/org/apache/commons/lang3/time/FastDateParserTest.java
----------------------------------------------------------------------
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 3651eae..1d86437 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);
+ }
}