【问题标题】:Hibernate using jvm time zone instead of what time zone we setHibernate 使用 jvm 时区而不是我们设置的时区
【发布时间】:2014-01-27 10:47:31
【问题描述】:

如果服务器在印度 - 在 IST 中存储时间戳值。 从美国运行服务器时 - 在 EST 中存储时间戳值。我正在使用 oracle 数据库和休眠 4.0。

请建议我如何解决这种差异。

我参考了下面的链接。

How can I get the current date and time in UTC or GMT in Java?

Hibernate TypeResolver

How to store date/time and timestamps in UTC time zone with JPA and Hibernate

Hibernate force timestamp to persist/load as UTC

Java, Hibernate, MySQL - store UTC date-time

【问题讨论】:

    标签: oracle hibernate datetime timezone timestamp


    【解决方案1】:

    我们可以使用“-Duser.timezone=US/Eastern”属性在任何时区启动服务器。

    【讨论】:

      【解决方案2】:

      从 Hibernate 5.2 开始,您现在可以通过以下配置属性强制使用可能与 JVM 不同的自定义时区:

      <property name="hibernate.jdbc.time_zone" value="US/Eastern"/>
      

      更多详情,请查看this article

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2019-09-16
        • 2014-10-18
        • 1970-01-01
        • 2016-01-30
        • 1970-01-01
        • 2022-01-24
        • 1970-01-01
        • 2011-10-27
        相关资源
        最近更新 更多