# Magic eight hours issue

Json format data submitted to the foreground, the background through @ResponsBody resolution, normal time is displayed 8:00:00 0:00:00 but the database

  • Solutions

* 1.后台有没有写死时间     【X】 
* 2.前台有没有传错值         【X】 
* 3.发现规律:前台传值只有格式是“yyyy-MM-dd” 类似这种格式才会出问题,而直接传时间戳是没问题
* 4.锁定是@ResponsBody 将日期自动装箱时对日期做了时区操作
* 5.搜索发现需要在实体类相关字段添加@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") 注解即可 
  • Think

1.需要了解@ResponsBody装箱底层实现
2.前台传值最好统一传时间戳格式 

Guess you like

Origin www.cnblogs.com/lifeisbitter/p/11411789.html