This is a discussion on JDK5 and TimeTest within the pgsql Interfaces jdbc forums, part of the PostgreSQL category; --> Hello, The TimeTest (jdbc2) fails for the tests with timezone while running the postgresql-jdbc tests using JDK5. This is ...
| |||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| 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().get RawOffset(); if (java.util.Calendar.getInstance().getTimeZone().in DaylightTime(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(TimeTe st.java:275) at org.postgresql.test.jdbc2.TimeTest.testSetTime(Tim eTest.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). |
| ||||
| On Fri, 18 Aug 2006, Hari wrote: > 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 see no failure here with JDBC 8.0.317, server 8.0.8 and JDK 1.5.0_05. > A simple Calendar code like this shows two different output under JDK > 1.4 and JDK5: > > Calendar c = Calendar.getInstance(); > System.out.println(c.toString()); I see identical results for my timezone (US/Pacific). Perhaps this change is specific to your zone (which you have not mentioned)? Kris Jurka ---------------------------(end of broadcast)--------------------------- TIP 2: Don't 'kill -9' the postmaster |