Spring boot 日期格式化


返回日期格式化

1,每个实体属性添加 @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone="GMT+8") 注解

2,可以在配置文件中全局指定

1, 每个实体属性添加 
    @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss", timezone="GMT+8")
2, 配置文件全局配置 
    spring.jackson.date-format=yyyy-MM-dd
    spring.jackson.time-zone=GMT+8

 

接受参数日期格式化

1, 每个实体属性添加 
  @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss") 2, 配置文件全局配置
  spring.mvc.date-format=yyyy-MM-dd HH:mm:ss

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM