Date formats/time zones

From: elliotl(at)start-global(dot)com
To: pgsql-jdbc(at)postgresql(dot)org
Subject: Date formats/time zones
Date: 2002-08-21 15:31:26
Message-ID: OF1F488329.CEF3038C-ON80256C1C.00535FA5@start-global.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

Hello. I am using the JDBC2.0 driver (pgjdbc2.jar) along with PostgreSQL
7.2.1 in a Java web app running on Tomcat 4.0.4. I've also imported Sun's
rowset.jar file so I can use the CachedRowSet object. I use both the
ResultSet and CachedRowSet objects in my code, and assumed their functions
to be identical. However, I have found a small discrepancy, and while I
have dealt with the problem, I'm still curous as to its origins.
The issue is that I'm implementing time zone support, and was quite pleased
to find that adding a date to a query in the form '21 Aug 2002 00:44:33
BST' was automatically translated to GMT before adding it to the database.
However, getting it out has proved more tricky. I've long since abandoned
using rs.getDate() to retrieve dates since it doesn't retireve time
information (which seems like a major oversight to me - though admittedly
not on your part!). Now I use getString and parse the date myself. Here's
where it gets strange. When I use rs.getString, I get a string like:
"2002-08-20 23:07:34+00". When I use the CachedRowSet object's getString
method (which is JDBC2.0) I get: "2002-08-21 00:07:34.0", the difference
being (aside from the . instead of +) is that the second one has already
been corrected for British Summer Time (BST)!. I've gotten around it by
only providing my own time correction only if a "+" is found, but I would
very much appreciate some kind of explanation for why this is happening!

Thanks for your time!

-Elliot Long

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Felipe Schnack 2002-08-21 19:44:50 OFF-TOPIC: stored procedures
Previous Message David Garnier 2002-08-20 20:40:31 Re: how to manage users of web-app