Skip to content

Conversion Error on LocalDate attribute when form-data request is sent to a Spring boot application

I send a form-data request from the Postman to a spring application. The LocalDate field in the Spring application as a text field from the form-data. I got a Conversion Error.

    name = "leasing_expiry",
    nullable = false
private LocalDate leasingExpiry;

Field error in object ‘vehicleDto’ on field ‘leasingExpiry’: rejected value [2021-01-01]; codes [typeMismatch.vehicleDto.leasingExpiry,typeMismatch.leasingExpiry,,typeMismatch]; arguments [ codes [vehicleDto.leasingExpiry,leasingExpiry]; arguments []; default message [leasingExpiry]]; default message [Failed to convert property value of type ‘java.lang.String’ to required type ‘java.time.LocalDate’ for property ‘leasingExpiry’; nested exception is org.springframework.core.convert.ConversionFailedException: Failed to convert from type [java.lang.String] to type [@javax.validation.constraints.NotBlank java.time.LocalDate] for value ‘2021-01-01’; nested exception is java.lang.IllegalArgumentException: Parse attempt failed for value [2021-01-01]]

Postman Request


As far as I understood, you have a problem with mapping String object into LocalDate object in Spring controller. Try annotate LocalDate field with following annotations:

@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd")
@DateTimeFormat(iso = DateTimeFormat.ISO.DATE)

and following dependency might be required:


I was facing with the same problem some day and it solved my issue.