Skip to content

Highlight that Duration and Period conversion is provided by the ApplicationConversionService and, by default, is not available for web conversion #22718

Closed
@jamestrandung

Description

@jamestrandung

Version: Spring Boot 2.3.2

I have the following simple TestController.

@RestController
@RequestMapping("/test")
public class TestController {
    @Getter
    protected static class TestObj {
        @DurationUnit(ChronoUnit.MINUTES)
        private Duration breakTime;
    }

    @GetMapping("/test")
    public void test(@RequestBody TestObj test) {
        System.out.println(test.getBreakTime());
    }
}

With the following body...

{
    "breakTime" : 30
}

... what I see in the console is

PT30S

Obviously, conversion is not happening. It always default to SECONDS.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions