Skip site navigation (1) Skip section navigation (2)

Re: Bug in TimestampUtils.java?

From: Richard Cook <awhig(at)yahoo(dot)com>
To: imad <immaad(at)gmail(dot)com>
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: Bug in TimestampUtils.java?
Date: 2006-11-10 16:07:21
Message-ID: 20061110160722.26453.qmail@web60223.mail.yahoo.com (view raw or flat)
Thread:
Lists: pgsql-jdbc
Yes. The switch from Daylight Savings time to Standard time 2 weeks ago revealed this bug to us.

Everything worked fine during Daylight Savings Time, 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 application broke because getDate() was returning a GMT -0400 Date, when we were now in GMT -0500. 

Rich




----- Original Message ----
From: imad <immaad(at)gmail(dot)com>
To: Richard Cook <awhig(at)yahoo(dot)com>
Cc: pgsql-jdbc(at)postgresql(dot)org
Sent: Friday, November 10, 2006 4:31:28 AM
Subject: Re: [JDBC] Bug in TimestampUtils.java?

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

--Imad
www.EnterpriseDB.com


On 11/10/06, Richard Cook <awhig(at)yahoo(dot)com> wrote:
>
> 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 to create a date
> or timestamp out of it. I think 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
>     {
>         return getDate(columnIndex, null);
>     }
>
>
>  public java.sql.Date getDate(int i, java.util.Calendar cal) throws
> SQLException
>     {
>         this.checkResultSet(i);
>
>         if (cal != null)
>             cal = (Calendar)cal.clone();
>
>         return connection.getTimestampUtils().toDate(cal, getString(i));
>     }
>
>
>
>
> ----- Original Message ----
> From: imad <immaad(at)gmail(dot)com>
> To: Richard Cook <awhig(at)yahoo(dot)com>
> Cc: pgsql-jdbc(at)postgresql(dot)org
> Sent: Thursday, November 9, 2006 4:54:15 PM
> Subject: Re: [JDBC] Bug in TimestampUtils.java?
>
> On 11/10/06, Richard Cook <awhig(at)yahoo(dot)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 Timestamp Column from Postgres as a Date. The data in the
> > database had a timezone of 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
> > that it should be -0500.
>
> I suggest you to confirm it with your database 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
>
>




pgsql-jdbc by date

Next:From: Heikki LinnakangasDate: 2006-11-10 16:07:52
Subject: Re: XA end then join fix for WebLogic
Previous:From: Mark LewisDate: 2006-11-10 14:36:21
Subject: Re: [Fwd: FAQ update about transaction interleaving]

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group