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

前端 未结 3 857
深忆病人
深忆病人 2021-02-08 01:48

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:42

    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

提交回复
热议问题