0

I'm passing the date in formDate as ISO date string yyyy-mm-ddThh:mm:ss.uuuZ

    @PostMapping
    @ResponseStatus(HttpStatus.CREATED)
    public void create(@Valid @ModelAttribute PersonRequest request, BindingResult bindingResult) {
        for( FieldError fieldError : bindingResult.getFieldErrors() )
            System.out.println(fieldError.getField() +" : "+fieldError.getDefaultMessage());
        personService.create(request);
    }

my PersonRequest class looks like this

@AllArgsConstructor
@NoArgsConstructor
@Data
@Builder
public class PersonRequest {

    private MultipartFile photo

    private String firstName;
    private String lastName;
    private Calendar dateOfBirth;

As I'm using Files I can't use RequestBody which did parse the date correctly

Ole V.V.
  • 81,772
  • 15
  • 137
  • 161
galalem
  • 389
  • 11
  • I strongly recommend you don’t use `Calendar`. That class is poorly designed, cumbersome to work with and long outdated. Assuming that for your date of birth you neither need time zone nor time of day, use `LocalDate` from [java.time, the modern Java date and time API](https://docs.oracle.com/javase/tutorial/datetime/). – Ole V.V. Feb 25 '23 at 10:35

0 Answers0