难以解决:Set Current TimeZone to @JsonFormat timezone value
各位大佬:
时间使用jackson的@JsonFormat进行格式化:
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date beginTime;
由于GMT+8这种常量不利于国际化。
我的方法:
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());
}
但是效果还是达不到,差了八个小时。请问怎么指定timezone为系统时区?