【发布时间】:2020-01-19 16:16:51
【问题描述】:
我有一个像这样存储上次更新日期的实体
@Entity
@Table(name = "counter")
public class Count {
@Id
@Column(name = "uniq_id")
String uniqId;
@Column(name = "amount")
int amount;
@Column(name = "points")
double points;
@Column(name = "handshake")
boolean handshake;
@UpdateTimestamp
@Temporal(TemporalType.TIMESTAMP)
@Column(name = "updated_date")
Date timestamp;
//getter setters
}
这部分
@UpdateTimestamp
@Temporal(TemporalType.TIMESTAMP)
@Column(name = "updated_date")
Date timestamp;
表示每当使用此实体时,timestamp 会自动更新并保留在数据库中。
现在我的问题是,如何在特定时区自动设置 timestamp?我正在使用 Postgresql。任何帮助,将不胜感激。
【问题讨论】:
-
A
Date没有时区,所以这可能是不可能的。 PostgreSQL 中的数据类型是什么? -
@OleV.V.该列在 Postgresql 中像这样
timestamp without time zone创建
标签: java postgresql hibernate spring-boot