I have a java program that generates timezone values in the binary format expected by Postgresql's COPY command in binary format. The data is written to a binary file which I then insert into Postgresql using the copy command into a table with a timestamp column (no time-zone).
The format is essentially the number 8 as a 4-byte value followed by microseconds since 2000-01-01 as an 8-byte value.
I am finding a difference in Postgresql and Java's interpretation of the timezone offset. When I attempt to write the date:
2004-11-01 09:34:42.432
which in the postgres binary format is
0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x8a, 0xcd, 0xe3, 0x10, 0x68, 0x00
and postgres reports the date correctly. However, if I enter the date
2010-11-01 09:34:42.432
which in binary goes as
0x00, 0x00, 0x00, 0x08, 0x00, 0x01, 0x36, 0xf8, 0x72, 0xcb, 0x64, 0x00
I get 2010-11-01 08:34:42.432 as the timestamp in Postgres.
Further investigation shows that Postgres thinks that the UTC offset is -5 for 2010 while Java thinks its -4 (which is correct I believe) leading to the one hour difference. Anyone know what the solution to this is?
Pertinent information:
Postgresql version 9.2.4
Java: 7
Working in Eastern Time Zone (America/New_York).
OS: Linux (timezone set correctly)