pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Thomas Kellerer <spam_eater@gmx.net>
To: pgsql-jdbc@postgresql.org
Subject: JDBC Driver and timezones
Date: Tue, 18 May 2010 11:29:37 +0200
Message-ID: <hstmm1$96v$1@dough.gmane.org> (raw)

Hi,

I have a little problem regarding timezones in the JDBC driver.

I have a locally installed Postgres server (PG 8.4.3 on Windows XP), so there is no difference between the timezone of the server and the client application.

When I run the following in psql:

select current_time, localtime;

I get the following output:

      timetz      |     time
-----------------+--------------
  11:15:30.464+02 | 11:15:30.464
(1 row)

which is fine.

Now when I run the same statement through JDBC :

Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery("select current_time, localtime");
if (rs.next())
{
   System.out.println("current_time: " + rs.getTime(1).toString());
   System.out.println("localtime: " + rs.getTime(2).toString());
}

I get the following output:

current_time: 10:18:49
localtime: 11:18:49

My expectation would have been to get the same display, but the current_time is one our off, which seems to be a problem with the daylight savings time.I

The timezone for my computer is setup correctly (the clock is showing the correct time, and apparently psql has the correct time as well)

The display from Java only works if I explicitely set the timezone when starting the JVM using -Duser.timezone=GMT+2

Is this a Java/JDK problem, a Windows problem or a driver problem?
I'm using JDK 1.6.0_18


Regards
Thomas




view thread (13+ messages)  latest in thread

Message-ID: <hstmm1$96v$1@dough.gmane.org>
Permalink:  ../hstmm1$96v$1@dough.gmane.org/
Also on:    postgresql.org/message-id/hstmm1$96v$1@dough.gmane.org

 · 

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: spam_eater@gmx.net
  Subject: Re: JDBC Driver and timezones
  In-Reply-To: <hstmm1$96v$1@dough.gmane.org>
  References: <hstmm1$96v$1@dough.gmane.org>

* 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