Reject 2-digit year with Spring @DateTimeFormat(style = "M-")

Viewed 48

My web-application is using Spring (spring-boot 2.4.2) and supports multiple locales (date formats). To format/parse Dates my form-object contains for example:

@DateTimeFormat(style = "M-")
private Date birthdate;

It is currently possible to enter 2-digit-year: When entering (german locale) "25.06.86" it is converted to "24.06.0086". I can't use pattern-attribute as I have to support multiple locales.

I want to show a form error when a 2-digit year is provided. How can I reject 2-digit-years?

0 Answers
Related