MySQL + springboot修改时区的方法

第一种方法:

在application-dev.yml配置文件增加以下配置:

spring:
  jackson:
    date-format: yyyy-MM-dd HH:mm:ss
    time-zone: GMT+8

第二种方法:

在实体类上加入如下注释:

   @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date createTime;
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date updateTime;

更改时区时,保证mysql的时区也是对的。

猜你喜欢

转载自blog.csdn.net/qq_36189144/article/details/83620919