Re: problem with dates when using a java calendar object with - Mailing list pgsql-jdbc

From Kris Jurka
Subject Re: problem with dates when using a java calendar object with
Date
Msg-id Pine.BSO.4.56.0410140656260.19030@leary.csoft.net
Whole thread Raw
In response to problem with dates when using a java calendar object with a non-default timezone  (Jair da Silva Ferreira Jr <j2@amazon.com.br>)
Responses Re: problem with dates when using a java calendar object with
List pgsql-jdbc

On Wed, 13 Oct 2004, Jair da Silva Ferreira Jr wrote:

> I don't care about the time (hour, minute and second)
> difference as this is a SQL DATE type. The problem is that the days in
> these dates are different.

There are a number of problems going on here:

First the JDBC driver didn't support using an alternate Calendar until
very recently.  This functionality is only in the 8.0 series.

Second it doesn't make sense to store a timezone with a date alone.  You
need time information as well, so you've selected the wrong pg datatype
"date" and should probably be using "timestamp with time zone".

Finally the javadoc says

    To conform with the definition of SQL DATE, the millisecond values
    wrapped by a java.sql.Date instance must be 'normalized' by
    setting the hours, minutes, seconds, and milliseconds to zero in
    the particular time zone with which the instance is associated.

I believe this means your whole setTimeInDate method is not legal.

Kris Jurka

pgsql-jdbc by date:

Previous
From: Kris Jurka
Date:
Subject: Re: tightening up on use of oid 0
Next
From: Paul Thomas
Date:
Subject: Re: PostgreSQL Database interfaced by Java Applet