Fork me on GitHub
#sql
<
2020-12-08
>
Daniel Stephens11:12:11

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!

seancorfield17:12:23

@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 Stephens13:12:52

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 Stephens16:12:18

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 Stephens16:12:26

Thanks for the help!