springboot接收日期参数
springboot接收日期参数?
springboot接收date类型参数
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