这是postgres jdbc处理postgres时间戳的错误吗?

时间:2015-09-25 02:09:15

标签: postgresql jdbc timestamp

关注此问题: how to use utc in postgres timestamp with jdbc PrepareStatement parameter?

现在我用

csv

上传日期值,

unicode

从postgres下载值。

但是,date.getTime()是UTC时区1970-01-01的毫秒数,它是静态的,与客户端时区无关,见下文

new java.sql.Timestamp(date.getTime() + date.getTimezoneOffset() * 60000)

看,1443145546920应始终 Fri Sep 25 2015 01:45:46 +0000 ,永远不要改变我的客户TimeZone。

所以,正确的方法应该是:

tstmp.getTime() - tstmp.getTimezoneOffset() * 60000

但是postgres jdbc以这种方式向我展示:

new Date(1443145546920)
Fri Sep 25 2015 09:45:46 GMT+0800 (中国标准时间)
*Now i change timezone from Beijing/Shanghai to Tokyo*
new Date(1443145546920)
Fri Sep 25 2015 10:45:46 GMT+0900 (Japan Standard Time)

0 个答案:

没有答案