What is the proper (recommended/documented) way to automatically deserialise a LocalDateTime request param in Spring Boot 3.
The url looks like http://localhost:8080/test?from=20221001000000
I have tried this solution and it does not work
@RequestMapping("/test")
public String index(@DateTimeFormat(pattern = "YYYYMMddHHmmss") java.time.LocalDateTime from) {
.....
}
I have tried this and it does not work neither. It does not even enter the custom deserialiser.
@RequestMapping("/test")
public String index(@JsonDeserialize(using = LocalDateTimeDeserializer.class) LocalDateTime from) {
........
}
@Override
public LocalDateTime deserialize(JsonParser jp, DeserializationContext dc) throws IOException, JacksonException {
....
}
The exception that I get is
[org.springframework.web.method.annotation.MethodArgumentTypeMismatchException: Failed to convert value of type 'java.lang.String' from required type 'java.time.LocalDateTime'; Failed to convert from type [java.lang.String] to type [@org.springframework.format.annotation.DateTimeFormat java.time.LocalDateTime] for value '20221001000000']