springboot 接口统一时间格式化
时间格式全局格式化
时间格式全局格式化
使用全局配置可以取代注解 @JsonFormat(pattern = " yyyy-MM-dd HH:mm:ss")
如果使用Date类型:
在application.yml中加入配置
spring:
jackson:
#时间戳统一转换
date-format: yyyy-MM-dd HH:mm:ss
#这个是时区,一定要加,否则会默认为格林尼治时间,即少8小时
time-zone: GMT+8

在使用spring框架开发经常会出现时间默认为格林尼治时间,需要在http接口转为当地时间再发送给前端
浙公网安备 33010602011771号