pgjdbc/pgjdbc GitHub issues and pull requests (mirror)
help / color / mirror / Atom feedFrom: kdubb (@kdubb) <[email protected]>
To: pgjdbc/pgjdbc <[email protected]>
Subject: [pgjdbc/pgjdbc] issue #1390: LocalDateTime has invalid string serialization
Date: Fri, 18 Jan 2019 16:58:38 +0000
Message-ID: <[email protected]> (raw)
The following shows that a `LocalDateTime` is always always tethered to the current time zone during insertion.
https://github.com/pgjdbc/pgjdbc/blob/ebada4afb25864bc2d8ba900b433a849c69decf8/pgjdbc/src/main/java/...
This is incorrect. A `timestamp` column has ___no___ timezone and therefore should never be altered during insertion/retrieval to a `timestamp` column. Tethering it to a time zone on insertion can (and does!) cause changes to the inserted time which are then apparent during retrieval.
The specific example is `SetObject310Text.testSetLocalDateTime` which tests a number of time zones including `Europe/Moscow`.
In that time zone it tests a time that exists in a one hour time void at `2000-03-26 2:00` (i.e 2:00 to 2:59 doesn't exist in Moscow on this date). During insertion the `LocalDateTime` value of `2000-03-26 2:00` is tethered to Moscow time and then formatted as a string which results in `2000-03-26 3:00` being inserted into the database due to the void.
The test itself even has to tether the `LocalDateTime` to a time zone just to test the value correctly.
https://github.com/pgjdbc/pgjdbc/blob/ebada4afb25864bc2d8ba900b433a849c69decf8/pgjdbc/src/test/java/...
Two issues
1. The time is still inserted _without_ a time zone so the tethering to Moscow time only affected the string conversion and then disappears.
1. This is a **local date/time** and the column it's inserting into is a `timestamp` (also _local_). If `2000-03-26 2:00` is inserted as `2000-03-26 3:00` in Moscow and read back in a different time zone it will have the wrong value for no explicable reason.
view thread (10+ messages) latest in thread
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: github://pgjdbc/pgjdbc
Cc: [email protected], [email protected]
Subject: Re: [pgjdbc/pgjdbc] issue #1390: LocalDateTime has invalid string serialization
In-Reply-To: <<[email protected]>>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox