Received: from localhost (wm.hub.org [200.46.204.128]) by postgresql.org (Postfix) with ESMTP id E40F39FA3A7 for ; Fri, 10 Nov 2006 12:07:41 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.128]) (amavisd-new, port 10024) with ESMTP id 78982-07 for ; Fri, 10 Nov 2006 16:07:23 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey- Received: from web60223.mail.yahoo.com (web60223.mail.yahoo.com [209.73.178.111]) by postgresql.org (Postfix) with SMTP id E653A9FB2F1 for ; Fri, 10 Nov 2006 12:07:22 -0400 (AST) Received: (qmail 26455 invoked by uid 60001); 10 Nov 2006 16:07:22 -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=t8DIvud9W8fFBta9F6nllhRdDLljBO58RA/C3H/EJCyWqCwmInS+GenL1rpFbdfTR/xTH6iaCHPjSUn38j12buRl2uC4GWNzbKr86tkQ8sTEMEEBZoTvsH0E+0UTkJHiQ5jlV7FzVIdAcb6YETXST79nLJC0tcFRQYn31iqjHtc= ; Message-ID: <20061110160722.26453.qmail@web60223.mail.yahoo.com> Received: from [65.223.207.194] by web60223.mail.yahoo.com via HTTP; Fri, 10 Nov 2006 08:07:22 PST Date: Fri, 10 Nov 2006 08:07:21 -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-1817990132-1163174841=:26274" X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200611/50 X-Sequence-Number: 16092 --0-1817990132-1163174841=:26274 Content-Type: text/plain; charset=ascii Content-Transfer-Encoding: quoted-printable Yes. The switch from Daylight Savings time to Standard time 2 weeks ago rev= ealed this bug to us.=0A=0AEverything worked fine during Daylight Savings T= ime, because it was GMT -0400. Because getDate() returns a GMT -0400 Date, = everything was good. As soon as we went to Standard Time, GMT -0500, our ap= plication broke because getDate() was returning a GMT -0400 Date, when we w= ere now in GMT -0500. =0A=0ARich=0A=0A=0A=0A=0A----- Original Message ----= =0AFrom: imad =0ATo: Richard Cook =0ACc:= pgsql-jdbc@postgresql.org=0ASent: Friday, November 10, 2006 4:31:28 AM=0AS= ubject: Re: [JDBC] Bug in TimestampUtils.java?=0A=0AI discussed this with a= colleague and he thinks this can be an issue of=0Adaylight saving time. Do= es that make sense to you?=0A=0A--Imad=0Awww.EnterpriseDB.com=0A=0A=0AOn 11= /10/06, Richard Cook wrote:=0A>=0A> Imad,=0A>=0A> If you = look at the source code for the postgres jdbc driver, it retrieves=0A> the = column as a string, then uses the TimeStampUtils class to create a date=0A>= or timestamp out of it. I think the driver is incorrectly setting the=0A> = timezone when it creates the Date object.=0A>=0A>=0A> From AbstractJdbc2Res= ultSet.java....=0A>=0A> public java.sql.Date getDate(int columnIndex) thro= ws SQLException=0A> {=0A> return getDate(columnIndex, null);=0A= > }=0A>=0A>=0A> public java.sql.Date getDate(int i, java.util.Calendar= cal) throws=0A> SQLException=0A> {=0A> this.checkResultSet(i);= =0A>=0A> if (cal !=3D null)=0A> cal =3D (Calendar)cal.c= lone();=0A>=0A> return connection.getTimestampUtils().toDate(cal, g= etString(i));=0A> }=0A>=0A>=0A>=0A>=0A> ----- Original Message ----=0A>= From: imad =0A> To: Richard Cook =0A> C= c: pgsql-jdbc@postgresql.org=0A> Sent: Thursday, November 9, 2006 4:54:15 P= M=0A> Subject: Re: [JDBC] Bug in TimestampUtils.java?=0A>=0A> On 11/10/06, = Richard Cook wrote:=0A> >=0A> > Hi All,=0A> >=0A> > I rec= ently ran into a problem that was partially caused by some behaviour=0A> I= =0A> > found in TimestampUtils.java. To me it does not seem right...=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 i= n GMT=0A> > -0500. If you look at the date that is returned from resultSet.= getDate()=0A> on=0A> > a Timestamp column, the timezone for the Date object= is -0400. I would=0A> think=0A> > that it should be -0500.=0A>=0A> I sugge= st you to confirm it with your database server. Try developing the=0A> same= =0A> scenario without JDBC and see what you get because connectors are not= =0A> supposed to play with the data they get. It is the server who formats= =0A> everything=0A> before sending it to the client.=0A>=0A> --Imad=0A> www= .EnterpriseDB.com=0A>=0A>=0A=0A=0A=0A=0A --0-1817990132-1163174841=:26274 Content-Type: text/html; charset=ascii Content-Transfer-Encoding: quoted-printable
Yes. The switch from Daylight Savings time to Standard time 2 weeks ago = revealed this bug to us.

Everything worked fine during Daylight Savi= ngs Time, because it was GMT -0400. Because getDate() returns a GMT -0400 D= ate, everything was good. As soon as we went to Standard Time, GMT -0500, o= ur application broke because getDate() was returning a GMT -0400 Date, when= we were now in GMT -0500.

Rich




----- Or= iginal Message ----
From: imad <immaad@gmail.com>
To: Richard C= ook <awhig@yahoo.com>
Cc: pgsql-jdbc@postgresql.org
Sent: Frida= y, November 10, 2006 4:31:28 AM
Subject: Re: [JDBC] Bug in TimestampUtil= s.java?

I discussed this with a colleague and he thinks this can be an issue of
d= aylight saving time. Does that make sense to you?

--Imad
www.EnterpriseDB.com<= br>

On 11/10/06, Richard Cook <awhig@yahoo.com> wrote:
>=
> Imad,
>
> If you look at the source code for the postg= res jdbc driver, it retrieves
> the column as a string, then uses the= TimeStampUtils class to create a date
> or timestamp out of it. I th= ink the driver is incorrectly setting the
> timezone when it creates = the Date object.
>
>
> From AbstractJdbc2ResultSet.java..= ..
>
>  public java.sql.Date getDate(int columnIndex)= throws SQLException
>     {
>  &= nbsp;      return getDate(columnIndex, null);
&= gt;     }
>
>
>  public jav= a.sql.Date getDate(int i, java.util.Calendar cal) throws
> SQLException
>=      {
>       = ;  this.checkResultSet(i);
>
>    &nbs= p;    if (cal !=3D null)
>    &nbs= p;        cal =3D (Calendar)cal.clone();=
>
>         return con= nection.getTimestampUtils().toDate(cal, getString(i));
>  &= nbsp;  }
>
>
>
>
> ----- Original Messag= e ----
> From: imad <immaad@gmail.com>
> To: Richard Cook= <awhig@yahoo.com>
> Cc: pgsql-jdbc@postgresql.org
> Sent= : Thursday, November 9, 2006 4:54:15 PM
> Subject: Re: [JDBC] Bug in = TimestampUtils.java?
>
> On 11/10/06, Richard Cook <awhig@ya= hoo.com> wrote:
> >
> > Hi All,
> >
> &= gt; 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 Timestamp Column from Pos= tgres as a Date. The data in the
> > database had a timezone of GM= T -0500, the current time was also in GMT
> > -0500. If you look a= t the date that is returned from resultSet.getDate()
> on
> >= ; a Timestamp column, the timezone for the Date object is -0400. I would> think
> > that it should be -0500.
>
> I suggest= you to confirm it with your database server. Try developing the
> sa= me
> scenario without JDBC and see what you get because connectors ar= e 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
>
&= gt;

--0-1817990132-1163174841=:26274--