JsonFormat的时间格式踩坑
使用JsonFormat注解来处理时间格式时,一定要注意规范写日期格式,否则会出现奇奇怪怪的时间转换bug
正确格式
@JsonFormat(partten="yyyy-MM-dd",timezone="GMT+8")
private Date startDate;
错误格式:输出的时间会变成每月1号
@JsonFormat(partten="yyyy-mm-dd",timezone="GMT+8")
private Date startDate;
正确格式
@JsonFormat(partten="yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
private Date startDate;
错误格式:输出时间会早10小时
@JsonFormat(partten="yyyy-MM-dd hh:mm:ss",timezone="GMT+8")
private Date startDate;

浙公网安备 33010602011771号