X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 4F2ED52F9C for ; Tue, 26 Jul 2005 00:02:46 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 73167-02 for ; Tue, 26 Jul 2005 03:02:40 +0000 (GMT) Received: from yass.opencloud.co.nz (yass.opencloud.co.nz [203.79.85.162]) by svr1.postgresql.org (Postfix) with ESMTP id 2A1C452C32 for ; Tue, 26 Jul 2005 00:02:36 -0300 (ADT) Received: from 203-79-104-60.cable.paradise.net.nz ([203.79.104.60] helo=[192.168.0.20]) by yass.opencloud.co.nz with asmtp (TLS-1.0:DHE_RSA_AES_128_CBC_SHA:16) (Exim 4.34) id 1DxFiF-00008U-Bb for pgsql-jdbc@postgresql.org; Tue, 26 Jul 2005 15:02:35 +1200 Message-ID: <42E5A7CA.6070109@opencloud.com> Date: Tue, 26 Jul 2005 15:02:34 +1200 From: Oliver Jowett User-Agent: Mozilla Thunderbird 1.0.2 (X11/20050324) X-Accept-Language: en-us, en MIME-Version: 1.0 To: "pgsql-jdbc@postgresql.org" Subject: TimeTest zone offset weirdness X-Enigmail-Version: 0.90.2.0 X-Enigmail-Supports: pgp-inline, pgp-mime Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.244 tagged_above=0 required=5 tests=AWL, TO_ADDRESS_EQ_REAL X-Spam-Level: X-Archive-Number: 200507/308 X-Sequence-Number: 13456 I'm currently looking at TimeTest.testGetTimeZone() which has: final Time midnight = new Time(0, 0, 0); Calendar cal = Calendar.getInstance(); cal.setTimeZone(TimeZone.getTimeZone("GMT")); long localOffset = Calendar.getInstance().get(Calendar.ZONE_OFFSET); [...] time = rs.getTime(1, cal); assertEquals(midnight.getTime() , time.getTime() + localOffset); The value in the database that's being retrieved is '00:00:00' -- it is a TIME WITHOUT TIME ZONE. As I interpret things: - 'midnight' should represent 1970-01-01 00:00:00 in the local timezone, i.e. local midnight. - 'time' should represent 1970-01-01 00:00:00 GMT, i.e. the database value interpreted in the provided (GMT) calendar. However as localOffset is the number of milliseconds that the local timezone is *ahead* of GMT, shouldn't that test be for 'time.getTime() - localOffset'? e.g. in the NZ timezone, localOffset is 43200000 (milliseconds) as NZ is 12 hours ahead of GMT in January 1970. Then midnight.getTime() is -43200000 as NZ reaches local midnight before GMT. Given that this doesn't fail in the current driver, presumably this means that getTime() is currently returning a Time with milliseconds = -86400000 ... which is surely wrong. With the timestamp-related changes I'm doing I also overhauled the Time and Date parsers; now getTime() is returning a Time with milliseconds = 0 and the assertion fails. Is this actually an existing test/driver error or am I misinterpreting what the behaviour should be? -O