时间相关注解

//指定前端接受的时间类型
@DateTimeFormat(pattern ="yyyy-MM-dd HH:mm:ss")
//从数据库查出来返回给前端的时间类型,一定要加时区,不然时间会不正确
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
private Date createTime;

//指定日期转成json字符串后的格式,不然会转成时间戳
@JSONField(format = "yyyy-MM-dd")
private Date createTime;

猜你喜欢

转载自www.cnblogs.com/minminlong/p/12530844.html
今日推荐