X-Original-To: pgsql-jdbc-postgresql.org@postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id 908339FB2FF for ; Tue, 22 Aug 2006 05:03:53 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 60466-07 for ; Tue, 22 Aug 2006 05:03:43 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from floppy.pyrenet.fr (floppy.pyrenet.fr [194.116.145.2]) by postgresql.org (Postfix) with ESMTP id 598C09FB352 for ; Tue, 22 Aug 2006 05:03:42 -0300 (ADT) Received: by floppy.pyrenet.fr (Postfix, from userid 106) id 1F83F30E02; Tue, 22 Aug 2006 10:03:39 +0200 (MET DST) From: "Hari" X-Newsgroups: pgsql.interfaces.jdbc Subject: JDK5 and TimeTest Date: 18 Aug 2006 12:02:07 -0700 Organization: http://groups.google.com Lines: 78 Message-ID: <1155927727.169145.64490@m73g2000cwd.googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" X-Complaints-To: groups-abuse@google.com User-Agent: G2/0.2 X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.0.6) Gecko/20060728 Firefox/1.5.0.6,gzip(gfe),gzip(gfe) Complaints-To: groups-abuse@google.com Injection-Info: m73g2000cwd.googlegroups.com; posting-host=209.10.209.56; posting-account=yyZLIQ0AAAB1fNg_T1rphiEw9hRxphtn To: pgsql-jdbc@postgresql.org X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.379 tagged_above=0 required=5 tests=DATE_IN_PAST_48_96 X-Spam-Level: X-Archive-Number: 200608/138 X-Sequence-Number: 15665 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).