两种方式:
1,可以在 pojo 类的每个时间属性上添加Jackson包的注解:
@JsonFormat(pattern=“yyyy-MM-dd HH:mm:ss”,timezone=“GMT+8”)
2,可以在全局配置文件中统一指定:
#时间的格式
spring.jackson.date-format=yyyy-MM-dd HH:mm:ss
#设置时区
spring.jackson.time-zone=GMT+8
#是否返回时间戳,如果三行配置同时存在,则以返回时间戳为准,一般不建议设置
#spring.jackson.serialization.write-dates-as-timestamps=false