- @DateTimeFormat(pattern = “yyyy-MM-dd”)
- @JsonFormat(timezone = “GMT+8”, pattern = “yyyy/MM/dd”)
@DateTimeFormat其实是作为Formatter被注册到ConvertionService中了
@JsonFormat被MappingJackson2HttpMessageConverter处理
@DateTimeFormat 处理:
POST /testdate3 HTTP/1.1
Host: localhost:8082
Content-Type: application/x-www-form-urlencoded
Cache-Control: no-cache
Postman-Token: c764abc6-768e-dab0-f46a-19037c33921a
name=asdf&date=2018-11-2+2%3A22%3A2
@JsonFormat处理:
POST /testdate HTTP/1.1
Host: localhost:8082
Content-Type: application/json
Cache-Control: no-cache
Postman-Token: e9017210-0f4d-c86c-51c8-18f7ccafc93d
{"name":"aaaa","id":1,"date":"2018/11/2 2:22:2"}