【发布时间】:2020-03-13 21:36:24
【问题描述】:
我的实体中的时间定义如下:
@Temporal(TemporalType.TIMESTAMP)
@Column(name = "start_time", length = 19, nullable = false)
public Date getStartTime() {
return this.startTime;
}
public void setStartTime(Date startTime) {
this.startTime = startTime;
}
然后像这样(简化)输出 JSON:
@GET
@RestSecure
@Path("/list")
@Produces(MediaType.APPLICATION_JSON)
public Response list(){
return Response.status(Response.Status.OK).entity(myEntityList).build();
}
是否有一种简单的方法来覆盖输出日期格式?
我得到的是这样的时代:
"startTime": 1582261711000,
我需要的是 ISO 8601 格式的日期,如下所示:
"startTime": "2020-02-21T05:08:31Z",
【问题讨论】:
标签: java json hibernate jpa jackson