JDK5 and TimeTest
От | Hari |
---|---|
Тема | JDK5 and TimeTest |
Дата | |
Msg-id | 1155927727.169145.64490@m73g2000cwd.googlegroups.com обсуждение исходный текст |
Ответы |
Re: JDK5 and TimeTest
|
Список | pgsql-jdbc |
Hello, The TimeTest (jdbc2) fails for the tests with timezone while running the postgresql-jdbc tests using JDK5. This is using pgsql-jdbc version 8.0.311 and postgresql version 8.0.6. I was wondering whether someone in the group has enountered the same and if there is a fix. I am just beginning to debug this and I have a feeling that it may be because the Calendar implementation JDK5 seems very different. Any ideas? Thanks very much! -Hari SpikeSource Inc. http://developer.spikesource.com ---------------------- Where it fails (org/postgresql/test/jdbc2/TimeTest.java): ==> The time is set in testSetTime (this works): ... ... ps.setObject(1, "5:1:2-03", java.sql.Types.TIME); assertEquals(1, ps.executeUpdate()); ps.setObject(1, "23:59:59+11", java.sql.Types.TIME); assertEquals(1, ps.executeUpdate()); ... ... ==> in timeTest method, the above time is accessed and it fails: ... ... // If we're checking for timezones. if (testSetTime) { assertTrue(rs.next()); t = rs.getTime(1); assertNotNull(t); java.sql.Time tmpTime = java.sql.Time.valueOf("5:1:2"); int localoffset = java.util.Calendar.getInstance().getTimeZone().getRawOffset(); if (java.util.Calendar.getInstance().getTimeZone().inDaylightTime(tmpTime)) { localoffset += 60 * 60 * 1000; } int Timeoffset = 3 * 60 * 60 * 1000; tmpTime.setTime(tmpTime.getTime() + Timeoffset + localoffset); assertEquals(makeTime(tmpTime.getHours(), tmpTime.getMinutes(), tmpTime.getSeconds()), t); // <=== fails here ... ... The error message is: expected:<00:01:02> but was:<05:01:02> junit.framework.AssertionFailedError: expected:<00:01:02> but was:<05:01:02> at org.postgresql.test.jdbc2.TimeTest.timeTest(TimeTest.java:275) at org.postgresql.test.jdbc2.TimeTest.testSetTime(TimeTest.java:201) A simple Calendar code like this shows two different output under JDK 1.4 and JDK5: import java.util.Calendar; class TestCalendar { public static void main(String[] args) { Calendar c = Calendar.getInstance(); System.out.println(c.toString()); } } (Execute it and look at the difference in the SimpleTimeZone object within the Calendar object. They look entirely different).
В списке pgsql-jdbc по дате отправления: