pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Charl Gerber <charlgerber@yahoo.com>
To: pgsql-jdbc@postgresql.org
Subject: timestamp issues
Date: Thu, 10 Mar 2005 14:03:45 +0000 (GMT)
Message-ID: <20050310140345.10534.qmail@web41203.mail.yahoo.com> (raw)

I have a machine physically located in the USA, but
the OS (Linux) time is set to New Zealand time. So if
I execute "date" on the command prompt, I get the New
Zealand time.

I have java classes converting all time to timezone
"Europe/Amsterdam". 

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.

If, however, I change the update to this:

"UPDATE users SET last_login=?"
with
prepareStatement.setTimestamp(1, new Timestamp(
    System.currentTimeMillis());

Then the java classes see the time correct as it
should.

Why is this? Why does System.currentTimeMillis() and
current_time give different times?




view thread (2+ messages)  latest in thread

Message-ID: <20050310140345.10534.qmail@web41203.mail.yahoo.com>
Permalink:  ../20050310140345.10534.qmail@web41203.mail.yahoo.com/
Also on:    postgresql.org/message-id/20050310140345.10534.qmail@web41203.mail.yahoo.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: charlgerber@yahoo.com
  Subject: Re: timestamp issues
  In-Reply-To: <20050310140345.10534.qmail@web41203.mail.yahoo.com>
  References: <20050310140345.10534.qmail@web41203.mail.yahoo.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