在数据库中存储的ZonedDateTime值与代码中的值不同。

huangapple 未分类评论47阅读模式
英文:

ZonedDateTime stored in DB with different value then in code

问题

在我的Java代码中,我执行以下操作:

.setModifiedDate(ZonedDateTime.now(ZoneOffset.UTC))

在调试器中,我看到的值是:2020-04-07T07:36:20.386321Z - 这是正确的

但是在Postgresql中,我看到的值是:2020-04-07 03:36:20 - 它不是在UTC时间。

数据库中modifided_date字段的数据类型是timestamptz。

如何将与代码中相同的值保存到数据库中?

英文:

In my Java code i do next:

.setModifiedDate(ZonedDateTime.now(ZoneOffset.UTC))

In debugger i see next value: 2020-04-07T07:36:20.386321Z - it is true

But in Postgresql i see next value: 2020-04-07 03:36:20 - It is not in UTC.

Field modifided_date id db have timestamptz type.

How to save to DB the same value as in code?

huangapple
  • 本文由 发表于 2020年4月7日 15:43:08
  • 转载请务必保留本文链接:https://java.coder-hub.com/61075083.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定