PostgreSQL 9.2 JDBC driver uses client time zone?

前端 未结 5 1620
遥遥无期
遥遥无期 2020-12-09 09:38

I\'ve run into an interesting challenge using a PostgreSQL database with the PostgreSQL JDBC driver. It seems that the latest version of the driver, 9.2, uses the client

5条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-09 10:12

    Short version try:

    TimeZone.setDefault(TimeZone.getTimeZone("UTC"));
    

    Hi we ran across this issue with client and server timezone miss match We needed our unit tests to be run using "UTC". By looking at the source code for postgres jdbc driver (and this being test code) we "fixed" it by changing the TZ inside of the jvm before obtaining a connection.

提交回复
热议问题