diff options
author | Martin Fietz <Martin.Fietz@gmail.com> | 2015-07-29 18:30:29 +0200 |
---|---|---|
committer | Martin Fietz <Martin.Fietz@gmail.com> | 2015-07-29 19:25:44 +0200 |
commit | 66e5c4fdf1325758e03a6146703ae2fd2c68f3db (patch) | |
tree | ef7784a30b1acadff479094cff94fd0cc9422b08 /core/src/androidTest | |
parent | af2ded8fe01a0589dc0030c4f981f6924765ef49 (diff) | |
download | AntennaPod-66e5c4fdf1325758e03a6146703ae2fd2c68f3db.zip |
Improve datetime parser
Diffstat (limited to 'core/src/androidTest')
-rw-r--r-- | core/src/androidTest/java/de/danoeh/antennapod/core/tests/util/DateUtilsTest.java | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/core/src/androidTest/java/de/danoeh/antennapod/core/tests/util/DateUtilsTest.java b/core/src/androidTest/java/de/danoeh/antennapod/core/tests/util/DateUtilsTest.java index 7429b50b3..2727b1447 100644 --- a/core/src/androidTest/java/de/danoeh/antennapod/core/tests/util/DateUtilsTest.java +++ b/core/src/androidTest/java/de/danoeh/antennapod/core/tests/util/DateUtilsTest.java @@ -13,6 +13,7 @@ public class DateUtilsTest extends AndroidTestCase { public void testParseDateWithMicroseconds() throws Exception { GregorianCalendar exp = new GregorianCalendar(2015, 2, 28, 13, 31, 4); + exp.setTimeZone(TimeZone.getTimeZone("UTC")); Date expected = new Date(exp.getTimeInMillis() + 963); Date actual = DateUtils.parse("2015-03-28T13:31:04.963870"); assertEquals(expected, actual); @@ -20,6 +21,7 @@ public class DateUtilsTest extends AndroidTestCase { public void testParseDateWithCentiseconds() throws Exception { GregorianCalendar exp = new GregorianCalendar(2015, 2, 28, 13, 31, 4); + exp.setTimeZone(TimeZone.getTimeZone("UTC")); Date expected = new Date(exp.getTimeInMillis() + 960); Date actual = DateUtils.parse("2015-03-28T13:31:04.96"); assertEquals(expected, actual); @@ -27,6 +29,7 @@ public class DateUtilsTest extends AndroidTestCase { public void testParseDateWithDeciseconds() throws Exception { GregorianCalendar exp = new GregorianCalendar(2015, 2, 28, 13, 31, 4); + exp.setTimeZone(TimeZone.getTimeZone("UTC")); Date expected = new Date(exp.getTimeInMillis() + 900); Date actual = DateUtils.parse("2015-03-28T13:31:04.9"); assertEquals(expected.getTime()/1000, actual.getTime()/1000); @@ -82,4 +85,20 @@ public class DateUtilsTest extends AndroidTestCase { assertEquals(expected, actual); } + public void testAsctime() throws Exception { + GregorianCalendar exp = new GregorianCalendar(2011, 4, 25, 12, 33, 00); + exp.setTimeZone(TimeZone.getTimeZone("UTC")); + Date expected = new Date(exp.getTimeInMillis()); + Date actual = DateUtils.parse("Wed, 25 May 2011 12:33:00"); + assertEquals(expected, actual); + } + + public void testMultipleConsecutiveSpaces() throws Exception { + GregorianCalendar exp = new GregorianCalendar(2010, 2, 23, 6, 6, 26); + exp.setTimeZone(TimeZone.getTimeZone("UTC")); + Date expected = new Date(exp.getTimeInMillis()); + Date actual = DateUtils.parse("Tue, 23 Mar 2010 01:06:26 -0500"); + assertEquals(expected, actual); + } + } |