JDBC Driver and timezones - Mailing list pgsql-jdbc

From Thomas Kellerer
Subject JDBC Driver and timezones
Date
Msg-id hstmm1$96v$1@dough.gmane.org
Whole thread Raw
Responses Re: JDBC Driver and timezones
Re: JDBC Driver and timezones
List pgsql-jdbc
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
theserver 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
problemwith 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
correcttime 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

pgsql-jdbc by date:

Previous
From: Craig Ringer
Date:
Subject: Re: Connection fails when the user name contains chinese characters
Next
From: Rod
Date:
Subject: After server restart I get - An I/O error occured while sending to the backend.