sql

All things SQL and JDBC...
Daniel Stephens 2020-12-08T11:16:11.441800Z

Hi, I asked this question: https://clojurians.slack.com/archives/C053AK3F9/p1607425780127500 about weird BC date conversion when querying postgres using clojure.java.jdbc and was pointed here. It may be an issue with the postgres JDBC driver https://github.com/pgjdbc/pgjdbc but wanted to see if anyone had any insight before I have to delve into code!

Daniel Stephens 2020-12-08T11:16:15.442200Z

Thanks

seancorfield 2020-12-08T17:04:23.445300Z

@dstephens Hmm, I haven't heard of anyone trying to use BCE dates with JDBC at all. goes to Bing Hmm, looks like numerous JDBC drivers have problems with that, historically, although some of those got logged as bugs and fixed. One thing you might try is calling .getTime on the value you get back to see whether the era is just being lost in printing.

Daniel Stephens 2020-12-09T13:18:52.445400Z

Thanks for that, I checked .getTime and it does appear to be negative so that's very useful! Strange that the .toLocalDate method gives back answers that don't line up with the underlying Date class at all but as you say, likely just something most people don't come across.

Daniel Stephens 2020-12-09T16:37:18.454200Z

so as you expected, seems the printing removes the era, the underlying julian calendar date is correct, as is the time, unfortunately I haven't found a nice conversion from the epochMillis to a local date again that lines up quite right, but it's close enough for my purposes!

Daniel Stephens 2020-12-09T16:37:26.454600Z

Thanks for the help!