pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Kris Jurka <books@ejurka.com>
To: Jair da Silva Ferreira Jr <j2@amazon.com.br>
Cc: pgsql-jdbc@postgresql.org
Subject: Re: problem with dates when using a java calendar object with
Date: Thu, 14 Oct 2004 07:10:31 -0500 (EST)
Message-ID: <Pine.BSO.4.56.0410140656260.19030@leary.csoft.net> (raw)
In-Reply-To: <416DB991.3060809@amazon.com.br>
References: <416DB991.3060809@amazon.com.br>



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



view thread (10+ messages)  latest in thread

Message-ID: <Pine.BSO.4.56.0410140656260.19030@leary.csoft.net>
Permalink:  ../Pine.BSO.4.56.0410140656260.19030@leary.csoft.net/
Also on:    postgresql.org/message-id/Pine.BSO.4.56.0410140656260.19030@leary.csoft.net

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-jdbc@postgresql.org
  Cc: books@ejurka.com, j2@amazon.com.br
  Subject: Re: problem with dates when using a java calendar object with
  In-Reply-To: <Pine.BSO.4.56.0410140656260.19030@leary.csoft.net>
  References: <416DB991.3060809@amazon.com.br> <Pine.BSO.4.56.0410140656260.19030@leary.csoft.net>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox