jackson对于java.util.Date时间转换的时候会发现少了8个小时,需要转换时间的Date都是采用JsonFormat处理的,目前解决方法:
1.objectMapper设置时区
objectMapper = new ObjectMapper(); //设置为中国上海时区 mapper.setTimeZone(TimeZone.getTimeZone("GMT+8"));
2.在JsonFormat里面指定时区(local和timezone都要)
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",locale = "zh",timezone = "GMT+8")
原文:http://www.cnblogs.com/visoncheng/p/4619944.html