I am using postgres server 8.3.7, JDBC driver postgresql-8.4-701.jdbc3.jar
In C:\PostgreSQL\data\postgresql.conf # CLIENT CONNECTION DEFAULTS ... timezone = 'GMT'
My application uses Spring and Hibernate and stores java.sql.Date in a table like this:
CREATE TABLE timeson ( id bigint NOT NULL, enddatetime timestamp without time zone NOT NULL, startdatetime timestamp without time zone NOT NULL, ... }
- My development machine is WinXP. The timezone is GMT+8. - The Postgres server report GMT as 'show timezone;" - I am running the Java Web application on the same machine as the Postgres server.
When I check the dates in the database using PGAdmin III on the client, I see the dates in the client timezone (GTM +8). If I do a TimeZone.setDefault(TimeZone.getTimeZone("GMT")) in my application, I see the dates with the "correct" (or expected) GMT timezone.
I don't understand why there is any timezone involved in reading and writing "timestamp without time zone". A quick check in the JDBC source code seems to show that the Java default timezone is used when no timezone is passed in when converting java.sql.Date
ava.sql.Date getDate(int i, java.util.Calendar cal) throws SQLException { checkResultSet(i); if (wasNullFlag) return null;
My goal is to be able to run a postgre server and a client in non GTM timezones and still being able to store java.sql.Date in GMT format, as they are defined in Java.