Java 8 OffsetDateTime clarification
David Wall <[email protected]> Mon, 6 May 2019 19:31:52 -0700
| Newsgroups | gmane.comp.db.postgresql.jdbc |
|---|---|
| Message-ID | <[email protected]> |
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