数据库连接时,读取到的时间会看到变少了八小时,是因为我们在东八区
解决方案为:
1.数据库连接和jackson的配置:
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://localhost:3306/db_shangxian_edu?useUnicode=true&characterEncoding=utf-8&serverTimezone=UTC&useSSL=false
username: root
password: xxx@
jackson:
#东八区 时间节点的配置
time-zone: GMT + 8
date-format: yyyy-MM-dd HH:mm:ss
2.添加jsonformat 注解
@ApiModelProperty(value = “入驻时间”)
@JsonFormat(timezone = “GMT+8”,pattern = “yyyy-MM-dd”)
private Date joinDate;