How to globally configure `@DateTimeFormat` pattern in Spring Boot?

前端 未结 3 1974
渐次进展
渐次进展 2021-02-08 02:01

Im my Spring Boot application, I have some controllers that accept a date as query parameter:

@RestController
public class MyController {

  @GetMapping
  public         


        
3条回答
  •  不思量自难忘°
    2021-02-08 02:40

    You can use spring.mvc.format.date, spring.mvc.format.time and spring.mvc.format.date-time

    For example:
    spring.mvc.format.time=HH:mm:ss
    spring.mvc.format.date=iso
    spring.mvc.format.date-time=iso-offset

    as in the example above, you can use shortcuts iso аnd iso-offset from spring boot 2.4.1

提交回复
热议问题