Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id CC4159FA5CE for ; Thu, 9 Nov 2006 18:37:59 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 55161-10 for ; Thu, 9 Nov 2006 18:37:55 -0400 (AST) X-Greylist: domain auto-whitelisted by SQLgrey- Received: from web60221.mail.yahoo.com (web60221.mail.yahoo.com [209.73.178.109]) by postgresql.org (Postfix) with SMTP id B07C89F9D99 for ; Thu, 9 Nov 2006 18:37:53 -0400 (AST) Received: (qmail 62562 invoked by uid 60001); 9 Nov 2006 22:37:52 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=Message-ID:Received:Date:From:Subject:To:Cc:MIME-Version:Content-Type; b=u92v7kgn5ySStRYWHbTeYIbxqE95QBywuZAEA5x7tUvwsvm3/q/WFG1Bh+BGPTwxnZJQGJcPK+KEKzerG0le6z4B41ldMUxNMQ4YAwZWadLxXwvykeF7bXE4BVyUdT6sBmnQLkhpXjO6IbW8/C6qATN2hzuOVMHqdpzbME2IHkQ= ; Message-ID: <20061109223752.62560.qmail@web60221.mail.yahoo.com> Received: from [65.223.207.194] by web60221.mail.yahoo.com via HTTP; Thu, 09 Nov 2006 14:37:52 PST Date: Thu, 9 Nov 2006 14:37:52 -0800 (PST) From: Richard Cook Subject: Re: Bug in TimestampUtils.java? To: imad Cc: pgsql-jdbc@postgresql.org MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="0-1655139145-1163111872=:60908" X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=2.122 tagged_above=0 required=5 tests=AWL, BAYES_00, DNS_FROM_RFC_ABUSE, DNS_FROM_RFC_POST, DNS_FROM_RFC_WHOIS, HTML_30_40, HTML_MESSAGE X-Spam-Level: ** X-Archive-Number: 200611/44 X-Sequence-Number: 16086 --0-1655139145-1163111872=:60908 Content-Type: text/plain; charset=ascii Content-Transfer-Encoding: quoted-printable Imad,=0A=0AIf you look at the source code for the postgres jdbc driver, it = retrieves the column as a string, then uses the TimeStampUtils class to cre= ate a date or timestamp out of it. I think the driver is incorrectly settin= g the timezone when it creates the Date object.=0A=0A=0AFrom AbstractJdbc2R= esultSet.java....=0A=0A public java.sql.Date getDate(int columnIndex) throw= s SQLException=0A {=0A return getDate(columnIndex, null);=0A }= =0A=0A=0A public java.sql.Date getDate(int i, java.util.Calendar cal) throw= s SQLException=0A {=0A this.checkResultSet(i);=0A=0A if (c= al !=3D null)=0A cal =3D (Calendar)cal.clone();=0A=0A ret= urn connection.getTimestampUtils().toDate(cal, getString(i));=0A }=0A=0A= =0A=0A=0A----- Original Message ----=0AFrom: imad =0ATo: = Richard Cook =0ACc: pgsql-jdbc@postgresql.org=0ASent: Thur= sday, November 9, 2006 4:54:15 PM=0ASubject: Re: [JDBC] Bug in TimestampUti= ls.java?=0A=0AOn 11/10/06, Richard Cook wrote:=0A>=0A> Hi= All,=0A>=0A> I recently ran into a problem that was partially caused by so= me behaviour I=0A> found in TimestampUtils.java. To me it does not seem ri= ght...=0A>=0A> I retrieved a Timestamp Column from Postgres as a Date. The = data in the=0A> database had a timezone of GMT -0500, the current time was = also in GMT=0A> -0500. If you look at the date that is returned from result= Set.getDate() on=0A> a Timestamp column, the timezone for the Date object i= s -0400. I would think=0A> that it should be -0500.=0A=0AI suggest you to c= onfirm it with your database server. Try developing the same=0Ascenario wit= hout JDBC and see what you get because connectors are not=0Asupposed to pla= y with the data they get. It is the server who formats everything=0Abefore = sending it to the client.=0A=0A--Imad=0Awww.EnterpriseDB.com=0A=0A=0A=0A=0A --0-1655139145-1163111872=:60908 Content-Type: text/html; charset=ascii Content-Transfer-Encoding: quoted-printable
Imad,

If you look at the source code for the postgres jdbc driver= , it retrieves the column as a string, then uses the TimeStampUtils class t= o create a date or timestamp out of it. I think the driver is incorrectly s= etting the timezone when it creates the Date object.


From Abstra= ctJdbc2ResultSet.java....

 public java.sql.Date getDate(int col= umnIndex) throws SQLException
    {
   =      return getDate(columnIndex, null);
  =   }


 public java.sql.Date getDate(int i, java.util.Cal= endar cal) throws SQLException
    {
   = ;     this.checkResultSet(i);

        = if (cal !=3D null)
         = ;   cal =3D (Calendar)cal.clone();

    = ;    return connection.getTimestampUtils().toDate(cal, getSt= ring(i));
    }




----- Original= Message ----
From: imad <immaad@gmail.com>
To: Richard Cook &l= t;awhig@yahoo.com>
Cc: pgsql-jdbc@postgresql.org
Sent: Thursday, N= ovember 9, 2006 4:54:15 PM
Subject: Re: [JDBC] Bug in TimestampUtils.jav= a?

On 11/10/06, Richard Cook <awhig@yahoo.com> wrote:
= >
> Hi All,
>
> I recently ran into a problem that was= partially caused by some behaviour I
> found in TimestampUtils.java.=   To me it does not seem right...
>
> I retrieved a T= imestamp Column from Postgres as a Date. The data in the
> database had a timezone o= f GMT -0500, the current time was also in GMT
> -0500. If you look at= the date that is returned from resultSet.getDate() on
> a Timestamp = column, the timezone for the Date object is -0400. I would think
> th= at it should be -0500.

I suggest you to confirm it with your databas= e server. Try developing the same
scenario without JDBC and see what you= get because connectors are not
supposed to play with the data they get.= It is the server who formats everything
before sending it to the client= .

--Imad
www.EnterpriseDB.com

--0-1655139145-1163111872=:60908--