我用的是Springmvc框架,数据库里使用的是时间戳保存时间类型,需要在前台显示Date类型的时间yyyy-MM-dd
只需要在model类中,加一个JsonFormat注解即可:
@JsonFormat(pattern="yyyy-MM-dd",timezone = "GMT+8")
public Date getTime() {
return Time;
}