Java 8 OffsetDateTime clarification

From: David Wall <d(dot)wall(at)computer(dot)org>
To: pgsql-jdbc(at)postgresql(dot)org
Subject: Java 8 OffsetDateTime clarification
Date: 2019-05-07 02:31:52
Message-ID: e0892e70-ffcb-6161-bbc9-3f710dd52593@computer.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

In the JDBC document about Java 8 date and times, it says, "Also note
that all OffsetDateTime instances will have be in UTC (have offset 0).
This is because the backend stores them as UTC.

Ref: https://jdbc.postgresql.org/documentation/head/java8-date-time.html

This seems incorrect to me.  The backend, when using TIMESTAMP WITH TIME
ZONE, stores the date+time+tzoffset, and they are not all 0 (for
example, PSQL SELECT show such fields like "2019-04-18
07:35:25.061-07".  And of course OffsetDateTime seems to align with
TIMESTAMP WITH TIME ZONE.  Lastly, I seem to be able to
ResultSet.getObject() and PreparedStatement.setObject() with
OffsetDateTime param without them all having offset 0 (I don't force the
OffsetDateTime to be in the UTC zone), and they look correct.

Can you clarify if that statement in the documentation is correct?  I
want to make sure I code this correctly as I'm updating from the older
use of java.sql.Timestamp for this purpose.

Thanks,
David

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Thomas Kellerer 2019-05-07 06:11:03 Re: Java 8 OffsetDateTime clarification
Previous Message Dave Cramer 2019-05-01 15:25:58 [pgjdbc/pgjdbc] 38041f: Fix maven coordinates