从前台保存数据到后台总是少了8个小时
结果看了一下是配置文件连接数据库url路径中服务器时间区域的问题:
原路径:jdbc:mysql://localhost:3306/*****?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=UTC&allowPublicKeyRetrieval=true
修改后的路径:
jdbc:mysql://localhost:3306/*****?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true
从后台获取数据在前台显示少了8个小时
解决方法:
在实体Bean加上@JsonFormat注解
@JsonFormat(pattern = "yyyy-MM-dd",timezone="GMT+8")
private Date crTime; //创建时间
@JsonFormat(timezone="GMT+8")
private Date ckTime; //审核时间
pattern根据自己的需求添加。