| From: | Lukas Eder <lukas(dot)eder(at)gmail(dot)com> | 
|---|---|
| To: | pgsql-jdbc(at)postgresql(dot)org | 
| Subject: | java.sql.ResultSet.getTime() returns wrong time | 
| Date: | 2010-09-19 13:16:57 | 
| Message-ID: | AANLkTinN6yX+=Wz+iZzsnWZhp4+bNfA7uRB+RoHsyoof@mail.gmail.com | 
| Views: | Whole Thread | Raw Message | Download mbox | Resend email | 
| Thread: | |
| Lists: | pgsql-jdbc | 
I have experienced a very peculiar issue with the postgresql JDBC driver
when calling java.sql.ResultSet.getTime() or getTimestamp() on a field of
type timetz.
Here is how to reproduce the issue:
   1. Set date and time to 2010-09-19 14:57:00 CEST (central european summer
   time: UTC+2) or something similar
   2. Fetch "SELECT current_time" from the Postgres database directly. This
   will return the correct time, e.g "14:57:17.116452+02"
   3. Fetch "SELECT current_time" from the Postgres JDBC driver. This will
   return a wrong time, e.g 13:57:17
After some debugging, I found out that in TimestampUtils.toTime(Calendar,
String), the date is zeroed out, i.e. 2010-09-19 is turned into 1970-01-01.
Of course, January 1 is CET (UTC+1) and not CEST (UTC+2), which explains the
result being one hour off. Since I'm requesting the current time on a day in
September, I would expect to receive the time as it is displayed in summer
time, and not on any arbitrary day in the past. I found some similar bug
reports on your archive with no solution yet, e.g.:
http://archives.postgresql.org/pgsql-jdbc/2010-05/msg00041.php
Cheers,
Lukas
| From | Date | Subject | |
|---|---|---|---|
| Next Message | admin | 2010-09-19 16:42:55 | Re: Broken pipe error | 
| Previous Message | Tom Lane | 2010-09-18 20:15:45 | Re: [JDBC] Trouble with COPY IN |