diff options
author | James Ahlborn <jtahlborn@yahoo.com> | 2012-10-15 03:45:09 +0000 |
---|---|---|
committer | James Ahlborn <jtahlborn@yahoo.com> | 2012-10-15 03:45:09 +0000 |
commit | bc30f4c1658d090767e37b8bd61df255b52d02af (patch) | |
tree | dd9bcb9d33d1b7dcabe8779c2ffd95194e917d39 /test | |
parent | 3f918ecfef9bbe4e5394aaacc55310fc3fedc876 (diff) | |
download | jackcess-bc30f4c1658d090767e37b8bd61df255b52d02af.tar.gz jackcess-bc30f4c1658d090767e37b8bd61df255b52d02af.zip |
Fix some more edge cases in date/time conversions (fixes issue 92)
git-svn-id: https://svn.code.sf.net/p/jackcess/code/jackcess/trunk@645 f203690c-595d-4dc9-a70b-905162fa7fd2
Diffstat (limited to 'test')
-rw-r--r-- | test/src/java/com/healthmarketscience/jackcess/DatabaseTest.java | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/test/src/java/com/healthmarketscience/jackcess/DatabaseTest.java b/test/src/java/com/healthmarketscience/jackcess/DatabaseTest.java index 1c0c2eb..5cb680c 100644 --- a/test/src/java/com/healthmarketscience/jackcess/DatabaseTest.java +++ b/test/src/java/com/healthmarketscience/jackcess/DatabaseTest.java @@ -1312,6 +1312,44 @@ public class DatabaseTest extends TestCase { } } + public void testTimeZone() throws Exception + { + TimeZone tz = TimeZone.getTimeZone("America/New_York"); + doTestTimeZone(tz); + + tz = TimeZone.getTimeZone("Australia/Sydney"); + doTestTimeZone(tz); + } + + private static void doTestTimeZone(final TimeZone tz) throws Exception + { + Column col = new Column(true, null) { + @Override + protected TimeZone getTimeZone() { return tz; } + }; + + SimpleDateFormat df = new SimpleDateFormat("yyyy.MM.dd"); + df.setTimeZone(tz); + + long startDate = df.parse("2012.01.01").getTime(); + long endDate = df.parse("2013.01.01").getTime(); + + Calendar curCal = Calendar.getInstance(tz); + curCal.setTimeInMillis(startDate); + + SimpleDateFormat sdf = new SimpleDateFormat("yyyy.MM.dd HH:mm:ss"); + sdf.setTimeZone(tz); + + while(curCal.getTimeInMillis() < endDate) { + Date curDate = curCal.getTime(); + Date newDate = new Date(col.fromDateDouble(col.toDateDouble(curDate))); + if(curDate.getTime() != newDate.getTime()) { + assertEquals(sdf.format(curDate), sdf.format(newDate)); + } + curCal.add(Calendar.MINUTE, 30); + } + } + private void checkRawValue(String expected, Object val) { if(expected != null) { |