| From: | Barry Lind <barry(at)xythos(dot)com> | 
|---|---|
| To: | elliotl(at)start-global(dot)com | 
| Cc: | pgsql-jdbc(at)postgresql(dot)org | 
| Subject: | Re: Date formats/time zones | 
| Date: | 2002-08-22 01:40:32 | 
| Message-ID: | 3D644110.1090207@xythos.com | 
| Views: | Whole Thread | Raw Message | Download mbox | Resend email | 
| Thread: | |
| Lists: | pgsql-jdbc | 
The first question I would ask is why you are not using the 
getTimestamp() method of the resultset?  You really don't want to be 
parsing the postgres dateformat unless you have to.
thanks,
--Barry
elliotl(at)start-global(dot)com wrote:
>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
>
>
>---------------------------(end of broadcast)---------------------------
>TIP 2: you can get off all lists at once with the unregister command
>    (send "unregister YourEmailAddressHere" to majordomo(at)postgresql(dot)org)
>
>  
>
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Bruce Momjian | 2002-08-22 02:05:49 | Re: DB Access Restrictions | 
| Previous Message | Dave Cramer | 2002-08-22 00:28:22 | Re: Update ResultSet for JDBC |