1,问题描述:

本人数据库里存的时间为:2018-01-31 10:00:01

后台代码取得时间属性列表是正确的,前端拿到的时间却变为了:2018-01-31 02:00:01

即少了8个小时

2, 解决方案:

在application.properties配置文件中添加如下时区配置即可:

spring.jackson.date-format=yyyy-MM-dd HH:mm:ss
spring.jackson.time-zone=GMT+8
属性日期格式化:
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") //此处与application.properties同时配置日期格式的话,会优先采用此处的格式
private Date beginTime;

相关文章:

  • 2021-12-05
  • 2021-10-16
  • 2022-12-23
  • 2021-10-07
  • 2021-11-17
  • 2022-12-23
猜你喜欢
  • 2021-10-23
  • 2022-12-23
  • 2021-09-06
  • 2021-08-06
  • 2021-05-22
  • 2022-02-11
相关资源
相似解决方案