For java.util.Date when I do
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = \"dd/MM/yyyy\")
private Date dateOfBirth;
<
If your request contains an object like this:
{
"year": 1900,
"month": 1,
"day": 20
}
Then you can use:
data class DateObject(
val day: Int,
val month: Int,
val year: Int
)
class LocalDateConverter : StdConverter() {
override fun convert(value: DateObject): LocalDate {
return value.run { LocalDate.of(year, month, day) }
}
}
Above the field:
@JsonDeserialize(converter = LocalDateConverter::class)
val dateOfBirth: LocalDate
The code is in Kotlin but this would work for Java too of course.