payara 服务器托管的 eclipselink 日期提前一小时从 postgres 读取

payara server hosted eclipselink dates are being read from postgres an hour early

我正在尝试从 postgres 数据库中读取时间戳值。 我尝试了各种映射,目前我正在使用以下映射:

@Column(name = "Anlagedatum")
private Timestamp anlagedatum;

如果我使用 SQL 查询数据库,我得到 第一个日期 2015-02-27.

如果我在本地机器上使用 scratch.java 执行 JPA 代码,我会得到 2015-02-27

当在 MY LOCAL Payara 服务器的上下文中执行完全相同的查询时,我得到一个不正确的日期。真正奇怪的部分是我的时区是 GMT +2,不是 +1

payara服务器返回的日期是2015-02-26 23:00:00

Why would payara server JPA change the date?
How do I change the mapping so that it gets the date stored without manipulation?

这看起来像是您所在时区的夏令时问题。

首先要检查的是您在 Postgresql 数据库中使用的列类型。
你应该使用:'timestamp with timezone';

如果已经是这种情况,您可以尝试以下操作:

@Temporal(javax.persistence.TemporalType.TIMESTAMP)
@Column(name = "Anlagedatum")
private Timestamp anlagedatum;

如果这没有帮助,我会尝试在 Java 中输入 'Date':

@Temporal(javax.persistence.TemporalType.TIMESTAMP)
@Column(name = "Anlagedatum")
private Date anlagedatum;