Skip site navigation (1) Skip section navigation (2)

Re: timestamp issues

From: Oliver Jowett <oliver(at)opencloud(dot)com>
To: Charl Gerber <charlgerber(at)yahoo(dot)com>
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: timestamp issues
Date: 2005-03-10 20:39:01
Message-ID: 4230B065.2040605@opencloud.com (view raw or flat)
Thread:
Lists: pgsql-jdbc
Charl Gerber wrote:

> I have tables with "TIMESTAMP" fields (no timezone).
> 
> If I do this (through a JDBC call):
> 
> "UPDATE users SET last_login=current_timestamp"
> 
> then the database explorer shows the times in New
> Zealand time, as expected. But my the Java classes see
> the time (after converting the time to the Amsterdam
> timezone) as 19 hours ahead of Amsterdam time. (19
> hours is, I think, the difference between the USA and
> New Zealand times?). I also tried with LOCALTIMESTAMP
> instead of current_timestamp, same result.

When you use getTimestamp() on a timestamp-without-timezone column, the 
JDBC driver treats it as a timestamp in the (Java client's) default 
timezone, a US timezone in your case I believe.

In theory you can pass an appropriate Calendar object to getTimestamp() 
to tell the driver to treat it as a timestamp in that timezone if no 
timezone information is associated with the timestamp column. The code 
looks a bit hairy though, I'd be interested to know if this actually works.

-O

In response to

pgsql-jdbc by date

Next:From: Dave CramerDate: 2005-03-10 20:43:44
Subject: Re: PostGreSQL Date Query?
Previous:From: Scott MarloweDate: 2005-03-10 20:38:53
Subject: Re: PostGreSQL Date Query?

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group