pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Oliver Jowett <oliver@opencloud.com>
To: Charl Gerber <charlgerber@yahoo.com>
Cc: pgsql-jdbc@postgresql.org
Subject: Re: timestamp issues
Date: Thu, 10 Mar 2005 20:39:01 +0000
Message-ID: <4230B065.2040605@opencloud.com> (raw)
In-Reply-To: <20050310140345.10534.qmail@web41203.mail.yahoo.com>
References: <20050310140345.10534.qmail@web41203.mail.yahoo.com>

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



view thread (2+ messages)

Message-ID: <4230B065.2040605@opencloud.com>
Permalink:  ../4230B065.2040605@opencloud.com/
Also on:    postgresql.org/message-id/4230B065.2040605@opencloud.com

 · 

reply

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: oliver@opencloud.com, charlgerber@yahoo.com
  Subject: Re: timestamp issues
  In-Reply-To: <4230B065.2040605@opencloud.com>
  References: <20050310140345.10534.qmail@web41203.mail.yahoo.com> <4230B065.2040605@opencloud.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