作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有两个 Java 应用程序通过 Hibernate 和 JPA 连接到 PostgreSQL 数据库。有没有办法让他们的连接模仿 set timezone
命令,以便在连接期间,时区的设置与数据库的默认时区不同?
最佳答案
自从commit 9d6b7930e6从2011年开始,JDBC驱动程序从JVM默认时区设置 session 时区。请参阅 java.util.TimeZone.getDefault()
的文档有关如何确定的详细信息:
- Use the
user.timezone
property value as the default time zone ID if it's available.- Detect the platform time zone ID. The source of the platform time zone and ID mapping may vary with implementation.
- Use GMT as the last resort if the given or detected time zone ID is unknown.
所以最简单的方法是在启动 JVM 时设置 user.timezone
属性:
java -Duser.timezone=UTC -cp ... MyProgram
关于java - 将 Java 连接到 PostgreSQL 时强制 TZ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58123614/
我正在开发一个 voip 调用应用程序。我需要做的是在接到来电时将 Activity 带到前台。我在应用程序中使用 Twilio,并在收到推送消息时开始调用。 问题是我试图在接到任何电话时显示 Act
我是一名优秀的程序员,十分优秀!