1、spring中添加配置
1、yml文件
spring:
jackson:
date-format: yyyy-MM-dd HH:mm:ss
time-zone: GMT+8
serialization:
#格式化输出
indent_output: true
#忽略无法转换的对象
fail_on_empty_beans: false
2、p'roperties文件
spring.jackson.date-format=yyyy-MM-dd HH:mm:ss
spring.jackson.time-zone=GMT+8
spring.jackson.serialization.indent_output=true
spring.jackson.serialization.fail_on_empty_beans=false
2、实体类中使用(变量单独使用)
@JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
public Date addtime;
注:数据返回出现2020-12-10T04:01:49.000+0000特殊时间,只需要在SpringBoot的配置文件里添加即可