@JsonFormat 默认是标准时区的时间,多出现少8小时的情况
使用时,按需求加上时区 北京时间 东八区 timezone=”GMT+8”
作用:后台的时间 格式化 发送到前台。
在网上看博客时,有看到@JsonFormat 涉及到夏时令的说法,可以参考博客:https://blog.youkuaiyun.com/weixin_37882382/article/details/91387401
@DateTimeFormat 接受前台的时间格式 传到后台的格式
import java.util.Date;
import org.springframework.format.annotation.DateTimeFormat;
import com.fasterxml.jackson.annotation.JsonFormat;
public class CusDevPlan {
private Integer id;
private String planItem;
@JsonFormat(pattern="yyyy-MM-dd",timezone="GMT+8")
@DateTimeFormat(pattern="yyyy-MM-dd")
private Date planDate;
...
}