From: Richard Cook <awhig@yahoo.com>
To: pgsql-jdbc@postgresql.org
Subject: Bug in TimestampUtils.java?
Date: Thu, 9 Nov 2006 12:16:29 -0800 (PST)
Message-ID: <20061109201629.17691.qmail@web60221.mail.yahoo.com> (raw)
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.
Here
is some sample code that illustrates the bug. Because TimestampUtils
does not have a public construct I made my own public class from the
source, to use in this example...
Thanks,
Rich
TODAY: 2006-11-09 15:06:31 -0500
Date String: 2006-10-29 23:00:00-05
Parsed date '2006-10-29 23:00:00-05' in zone
America/New_York as 2006-10-29 AD 00:00:00 -0400 (millis=1162094400000)
Converted Date: 2006-10-29 00:00:00 -0400
TimestampUtils utils = new TimestampUtils(true);
SimpleDateFormat formatter = new SimpleDateFormat(
"yyyy-MM-dd HH:mm:ss Z");
Date theTime;
try {
System.out.println("TODAY: " + formatter.format(new Date()));
String dateString = "2006-10-29 23:00:00-05";
System.out.println("Date String: " + dateString);
theTime =
utils.toDate(null,dateString);
System.out.println("Converted Date: " + formatter.format(theTime));
} catch (SQLException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
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: awhig@yahoo.com
Subject: Re: Bug in TimestampUtils.java?
In-Reply-To: <20061109201629.17691.qmail@web60221.mail.yahoo.com>
References: <20061109201629.17691.qmail@web60221.mail.yahoo.com>
* 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