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

Invalid Time Exception While Reading Timestamp #24

Open
edalorzo opened this issue Jul 3, 2016 · 1 comment
Open

Invalid Time Exception While Reading Timestamp #24

edalorzo opened this issue Jul 3, 2016 · 1 comment
Assignees
Labels

Comments

@edalorzo
Copy link

edalorzo commented Jul 3, 2016

Very interesting project. I like it very much. I hope it becomes mature enough to be used in production settings soon.

I found this library the other after playing a bit with the Spring Reactive Playground project.

So I decided to write a small reactive application today. I wrote a very simple program that was intended to read a row from a table in my database. I have a field last_modified which is a timestamp. When I try to read the field doing a row.getTimestamp() I get an SqlException:

com.github.pgasync.SqlException: Invalid time: 2016-07-01 09:00:05-06
    at com.github.pgasync.impl.conversion.TemporalConversions.toTimestamp(TemporalConversions.java:90)
    at com.github.pgasync.impl.conversion.DataConverter.toTimestamp(DataConverter.java:63)
    at com.github.pgasync.impl.PgRow.getTimestamp(PgRow.java:174)
...

The problem seems to be located in the TemporalConversions.toTimstamp() method as you can see. It appears that the default configuration for timestamp is not working for me out of the box.

My date format seems to be yyyy-MM-dd HH:mm:ssX but the one given in the toTimestamp() is yyyy-MM-dd HH:mm:ss.SSS and this breaks my code.

Not sure why the driver chooses that particular date time format, but I suppose it does not apply to all PostgreSQL configurations.

I wonder if the format can be configured somehow without I having to write my own Timestamp converter, but otherwise you may want to look into this issue or perhaps offer a way to configure the format either globally or in the toTimestamp() function.

To make things worse I cannot retrieve the value neither as a string or as a long without getting an "unsupported conversion exception", so basically I cannot retrieve the record from the database simply because my timestamp format is different.

@alaisi alaisi added the bug label Jul 3, 2016
@alaisi alaisi self-assigned this Jul 3, 2016
@alaisi
Copy link
Owner

alaisi commented Jul 6, 2016

Thanks for the bug report. Can you verify that the exception occurs when using version 0.9 of the library?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants