X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 66517D793E for ; Fri, 2 Sep 2005 06:40:42 -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 25198-09 for ; Fri, 2 Sep 2005 09:40:36 +0000 (GMT) Received: from outmail.unitedplanet.de (guardian.unitedplanet.de [212.185.176.178]) by svr1.postgresql.org (Postfix) with ESMTP id 9AB0DD78F9 for ; Fri, 2 Sep 2005 06:40:34 -0300 (ADT) Received: from Apollo.unitedplanet.de (apollo.unitedplanet.de [10.10.12.17]) by outmail.unitedplanet.de (Postfix) with ESMTP id 99E143FA11 for ; Fri, 2 Sep 2005 11:56:21 +0200 (CEST) Received: from [10.10.15.18] ([10.10.15.18]) by Apollo.unitedplanet.de with Microsoft SMTPSVC(6.0.3790.1830); Fri, 2 Sep 2005 11:40:35 +0200 Message-ID: <43181E09.8010503@unitedplanet.de> Date: Fri, 02 Sep 2005 11:40:25 +0200 From: Martin Keller User-Agent: Mozilla Thunderbird 1.0.6 (X11/20050725) X-Accept-Language: en-us, en MIME-Version: 1.0 To: pgsql-jdbc@postgresql.org Subject: Re: timestamp moves when setting and getting a value from References: <431810FD.8090604@elver.org> In-Reply-To: <431810FD.8090604@elver.org> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 02 Sep 2005 09:40:35.0600 (UTC) FILETIME=[5E903900:01C5AFA2] X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0 required=5 tests=[none] X-Spam-Level: X-Archive-Number: 200509/11 X-Sequence-Number: 13796 Hi Martin, this issue was discussed in several threads a few weeks ago. There is a patch by Oliver Jowett commited to the head branch of the project. It's not in the current 312 release. **** Martin Martin Taal wrote: > Hi, > I have a problem when saving and retrieving a timestamp from postgresql. > When I save a timestamp and retrieve it it gets moved two hours (my > timezoneoffset from gtm). > > For example when I store 2 Sept. 2005 10:12:12 + 2. I get 2 Sept. > 12:12:12+2 back. > When I look in postgresql (psql and then commandline select * from > table) then I can see that it stores 2 Sept. 12:12:12+2 in the > timestamp field although the time I pass in is 2 Sept. 2005 10:12:12 + 2. > > Environment: > linux > postgresql 8.0.2 > latest jdbc driver: 8.0-312 jdbc 2 > > The field type in the database is timestamptz > > I debugged through the method setTimeStamp method and getTimeStamp > methods in > AbstractJDBC2Statement. My input to setTimeStamp: > a timestamp 2 Sept. 10:12:12 CEST > a calendar with timezone UTC > > This results in the database in the timestamptz field in a value: 2 > Sept. 2005 12:12:12 + 2. > In gettimestamp this same value is returned. > > It seems that the changeTime method in AbstractJDBC2Statement actually > adds two hours (should it not subtract 2 hours to get from CEST to > GMT?) in addition the time zone of the computed value is set to CEST > while I pass a UTC calendar (so the timestamp field in the database > should actually contain: 2 Sept. 2005 8:12:12 + 0. > > As an extra info the setTimeStamp(int, timestamp, calendar) method > calls setTimeStamp(int, timestamp) method. In this > last method a new GregorianCalendar is created. The timezone of this > new calendar is Europe/Amsterdam (my system timezone apparently). > > I tried different things like instead of passing in a calendar with > UTC timezone, I tried Europe/Amsterdam. But this gave the same result. > The timezone setting of postgresql is Europe/Amsterdam. > > Did I miss something or am I doing something wrong? > I am sorry if I missed something obvious. >