使用Jackson的@JsonFormat注解时出现少八个小时

    xiaoxiao2021-03-25  174

    使用Jackson的@JsonFormat注解时出现少八个小时 比如数据库存的日期是2015-01-05,转成json则变成了2015-01-04 解决办法: @JsonFormat(pattern="yyyy-MM-dd")  public Date getRegistDate() {   return this.registDate;  } 改成 @JsonFormat(pattern="yyyy-MM-dd",timezone="GMT+8")  public Date getRegistDate() {   return this.registDate;  } 加上时区即可,中国是东八区
    转载请注明原文地址: https://ju.6miu.com/read-3236.html

    最新回复(0)