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 D2A7D533B2 for ; Mon, 2 May 2005 08:22:44 -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 78317-08 for ; Mon, 2 May 2005 11:22:36 +0000 (GMT) Received: from outmail.unitedplanet.de (guardian.unitedplanet.de [212.185.176.178]) by svr1.postgresql.org (Postfix) with ESMTP id 0C4D753860 for ; Mon, 2 May 2005 08:22:35 -0300 (ADT) Received: from Apollo.unitedplanet.de (apollo.unitedplanet.de [10.10.12.17]) by outmail.unitedplanet.de (Postfix) with ESMTP id AE75B33776 for ; Mon, 2 May 2005 13:36:29 +0200 (CEST) Received: from [10.10.15.19] ([10.10.15.19]) by Apollo.unitedplanet.de with Microsoft SMTPSVC(6.0.3790.211); Mon, 2 May 2005 13:22:38 +0200 Message-ID: <42760D89.8080404@unitedplanet.de> Date: Mon, 02 May 2005 13:22:49 +0200 From: Martin Keller User-Agent: Debian Thunderbird 1.0.2 (X11/20050331) X-Accept-Language: en-us, en MIME-Version: 1.0 To: pgsql-jdbc@postgresql.org Subject: Re: Problems storing timestamps with calendars References: <426FBDA4.2010306@unitedplanet.de> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 02 May 2005 11:22:38.0004 (UTC) FILETIME=[3EFDAF40:01C54F09] X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= X-Spam-Level: X-Archive-Number: 200505/6 X-Sequence-Number: 12837 Hello Kris, unfortunately, this fix doesn't solve the problem. As far as I understand, this topic isn't that much complicated: - Date#getTime() returns the number of milliseconds since January 1, 1970, 00:00:00 GMT. It's not affected by the timezone of the date object. So there's no need to consider the (deprecated) timezone offset. - Timezone#getOffset() takes care of the daylight savings. It's not a good idea to do this by your self since (so far as I know) there are regions on the earth with daylight savings which defer from one hour. I checked the behaviour of setTimeStamp against some other databases ( Oracle, DB2, MS SQL with jTDS) and they did all the same. Maybe the following comparison can help you. All Servers and the java vm are running in the same timezone (Europe/Berlin, summertime). Input DB Content PostgreSQL Oracle/DB2/MS SQL 1.1.1970 00:00:00 UTC, no calendar specified 1970-01-01 01:00:00 1970-01-01 01:00:00 1.1.1970 00:00:00 UTC with UTC calendar 1970-01-01 02:00:00 1970-01-01 00:00:00 1.1.1970 00:00:00 UTC with CET calendar 1970-01-01 01:00:00 1970-01-01 01:00:00 1.1.1970 00:00:00 UTC mit America/Montreal-calendar 1970-01-01 07:00:00 1969-12-31 19:00:00 Regards, Martin Kris Jurka wrote: >On Wed, 27 Apr 2005, Martin Keller wrote: > > > >>We have some trouble with storing timestamps via >>PreparedStatement.setTimestamp(int, Timestamp, Calendar) into a >>timestamp column without timezone. >>It looks like that the timestamp values are adjusted in the wrong >>direction if the timezone of the calendar is not the default timezone of >>the java vm. >> >>Are we doing anything wrong or is this a bug? >> >> >> > >Something is definitely wrong here. At first glance it doesn't look >like it's related to the vm timezone, but instead >AbstractJdbc2Statement.changeTime should be respecting Add for the DST >offset, but I'm not quite sure of that. It gets complicated when you've >got to consider four different possible timezones (server, vm, timestamp, >calendar). Does this jar file fix things for you? > >http://www.ejurka.com/pgsql/jars/mk/ > >Kris Jurka > >