springboot接收日期类型参数,实现自动转换。

1. 当请求类型为json,date类型字段为 json 字段时,可以使用如下两种方法

  1.1. 当前参数加两个注解(有些文章说接收只需要加 @DateTimeFormat,我试了,不行)

  @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
    private Date pageTime;

  1.2. 全局配置

    application.properties文件添加:

spring.jackson.date-format=yyyy-MM-dd HH:mm:ss
spring.jackson.time-zone=GMT+8

 

  

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-11-17
  • 2022-01-01
  • 2021-07-15
  • 2022-12-23
  • 2021-10-12
猜你喜欢
  • 2022-12-23
  • 2021-09-14
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-04-04
相关资源
相似解决方案