Re: problem with dates when using a java calendar object with

From: Kris Jurka <books(at)ejurka(dot)com>
To: Jair da Silva Ferreira Jr <j2(at)amazon(dot)com(dot)br>
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: problem with dates when using a java calendar object with
Date: 2004-10-14 12:10:31
Message-ID: Pine.BSO.4.56.0410140656260.19030@leary.csoft.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Paul Thomas 2004-10-14 13:03:16 Re: PostgreSQL Database interfaced by Java Applet
Previous Message Kris Jurka 2004-10-14 11:49:18 Re: tightening up on use of oid 0