Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reading timestamps from PostgreSQL #299

Open
jehatz opened this issue Feb 27, 2023 · 0 comments
Open

Reading timestamps from PostgreSQL #299

jehatz opened this issue Feb 27, 2023 · 0 comments
Assignees
Labels

Comments

@jehatz
Copy link

jehatz commented Feb 27, 2023

Version

Vertx 4.3.8, vertx-jdbc-clinet 4.3.8

Context

We have a PostgreSQL table with columns of TIMESTAMP WITH TIME ZONE.

Whenever we read a certain timestamp where the seconds are by accident zero, e.g.
2023-02-09 14:16:00 then we get back a OffsetDateTime object where the seconds are cut, e.g. 2023-02-09T13:16Z.

Finally, this representation can't be deserialized into java.time.Instant.

com.fasterxml.jackson.databind.exc.InvalidFormatException: Cannot deserialize value of type `java.time.Instant` from String "2023-02-09T13:16Z": Failed to deserialize java.time.Instant: (java.time.format.DateTimeParseException) Text '2023-02-09T13:16Z' could not be parsed at index 16

Caused by: java.time.format.DateTimeParseException: Text '2023-02-09T13:16Z' could not be parsed at index 16
at java.base/java.time.format.DateTimeFormatter.parseResolved0(DateTimeFormatter.java:2056)
at java.base/java.time.format.DateTimeFormatter.parse(DateTimeFormatter.java:1884)
at com.fasterxml.jackson.datatype.jsr310.deser.InstantDeserializer._fromString(InstantDeserializer.java:302)

Timestamps with seconds not equal to zero are deserialized as expected.

To deserialize all fetched data into our objects we use the idiom

<row>.toJson().mapTo(<POJO>.class)

which calls in our context the toString() method of the OffsetDateTime property of the target class.

Do you have a reproducer?

Unfortunately, no

Steps to reproduce

  1. In a postgreSQL database create a colum of type TIMESTAMP WITH TIME ZONE
  2. Insert a value where the seconds are zero, e.g. 2023-02-09 14:16:00
  3. try to deserialize into a type of java.time.Instant`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

2 participants