springboot 返回Date类型数据 格式化



1.提示类的get方法上增加JsonFormat

@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    public Date getCreateTime() {
        return createTime;
    }

2.或者在配置文件中增加

spring:
  jackson:
 date-format: yyyy-MM-dd HH:mm:ss
 time-zone: GMT+8
原文地址:https://www.cnblogs.com/paisen/p/10302251.html