admin管理员组文章数量:1026989
java 设置timezone
各位大佬:
从数据库查到的时间使用jackson的@JsonFormat进行格式化:
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date beginTime;
由于GMT+8这种常量不利于国际化,所以我想使用系统时区作为timezone。
我的方法:
1 使用默认时区
@JsonFormat(shape = JsonFormat.Shape.STRING,pattern = "HH:mm",timezone = JsonFormat.DEFAULT_TIMEZONE)
private Date timeQuantumBegin;
2 配置objectMapper,设置系统时区
@Autowired
public void configureJackson(ObjectMapper objectMapper) {
objectMapper.setTimeZone(TimeZone.getDefault());
}
但是效果还是达不到,差了八个小时。请问是我哪里做的不对吗?
java 设置timezone
各位大佬:
从数据库查到的时间使用jackson的@JsonFormat进行格式化:
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date beginTime;
由于GMT+8这种常量不利于国际化,所以我想使用系统时区作为timezone。
我的方法:
1 使用默认时区
@JsonFormat(shape = JsonFormat.Shape.STRING,pattern = "HH:mm",timezone = JsonFormat.DEFAULT_TIMEZONE)
private Date timeQuantumBegin;
2 配置objectMapper,设置系统时区
@Autowired
public void configureJackson(ObjectMapper objectMapper) {
objectMapper.setTimeZone(TimeZone.getDefault());
}
但是效果还是达不到,差了八个小时。请问是我哪里做的不对吗?
本文标签: java 设置timezone
版权声明:本文标题:java 设置timezone 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/IT/1694660674a254666.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论