今天使用以下代码格式日期字段

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date createTime;

发现这样渲染出来的日期小时分钟数不对,少了8个小时,这是由于@JsonFormat,默认情况下timeZone为GMT(即标准时区),所以会造成少8小时,改为以下就正常

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

这样就改为标准北京时间,中国是东八区

相关文章:

  • 2022-12-23
  • 2021-12-30
  • 2022-12-23
  • 2022-12-23
  • 2021-08-30
  • 2021-05-16
猜你喜欢
  • 2022-03-07
  • 2021-12-25
  • 2022-12-23
  • 2021-06-22
  • 2021-09-26
  • 2022-01-21
相关资源
相似解决方案