Skip to content

Spring Boot 3 - Query params to POJO deserialisation via @DateTimeFormat does not work any more #33390

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
vvararu opened this issue Nov 28, 2022 · 1 comment
Labels
status: invalid An issue that we don't feel is valid

Comments

@vvararu
Copy link

vvararu commented Nov 28, 2022

Hi,

Having these pieces of code, tried to upgrade from Spring boot 2.X to 3.0

Controller:

@Slf4j
@RestController
public class MyController {

    @RequestMapping("/cc/query/{breakdown}")
    public Mono<QueryResult> getBreakdown(@PathVariable String breakdown, QueryParams queryParams) {

And the POJO container of the request parameters:

import org.joda.time.LocalDateTime;

@Data
public class QueryParams {

    @NotBlank
    @DateTimeFormat(pattern = "YYYYMMddHHmmss")
    private LocalDateTime from;

}

This works well with Spring boot 2.7.6 but crashes with Spring boot 3.0:

DefaultHandlerExceptionResolver : Resolved [org.springframework.validation.BindException: org.springframework.validation.BeanPropertyBindingResult: 1 errors<EOL>Field error in object 'queryParams' on field 'from': rejected value [20221001000000]; codes [typeMismatch.queryParams.from,typeMismatch.from,typeMismatch.org.joda.time.LocalDateTime,typeMismatch]; arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [queryParams.from,from]; arguments []; default message [from]]; default message [Failed to convert property value of type 'java.lang.String' to required type 'org.joda.time.LocalDateTime' for property 'from'; Cannot convert value of type 'java.lang.String' to required type 'org.joda.time.LocalDateTime' for property 'from': no matching editors or conversion strategy found]]
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Nov 28, 2022
@wilkinsona
Copy link
Member

wilkinsona commented Nov 28, 2022

Support for Joda Time has been removed in the latest major release of spring Data. This is also covered in the Spring Data release notes. Please use the equivalent java.time classes instead.

@wilkinsona wilkinsona closed this as not planned Won't fix, can't repro, duplicate, stale Nov 28, 2022
@wilkinsona wilkinsona added status: invalid An issue that we don't feel is valid and removed status: waiting-for-triage An issue we've not yet triaged labels Nov 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: invalid An issue that we don't feel is valid
Projects
None yet
Development

No branches or pull requests

3 participants