I trying to use java 8 LocalDate with springboot
I put
compile ("com.fasterxml.jackson.datatype:jackson-datatype-jsr310")
int .gradle
and
@JsonDeserialize(using = LocalDateDeserializer.class)
@JsonSerialize(using = LocalDateSerializer.class)
private LocalDate dia;
in properties I have:
spring.jackson.date-format=dd/MM/yyyy HH:mm:ss
but dont work, when I try to post I got this error:
{
"timestamp": "02/09/2015 11:32:15",
"status": 400,
"error": "Bad Request",
"exception": "org.springframework.http.converter.HttpMessageNotReadableException",
"message": "Could not read document: Text '10/10/2015' could not be parsed at index 0 (through reference chain: br.com.lumera.entity.Feriado[\"dia\"]); nested exception is com.fasterxml.jackson.databind.JsonMappingException: Text '10/10/2015' could not be parsed at index 0 (through reference chain: br.com.lumera.entity.Feriado[\"dia\"])",
"path": "/atos/feriado/"
}
how can I fix this?
tks
By default, the format accepted by the LocalDateDeserializer
class is yyyy-mm-dd. You'll have to modify your frontend component so it formats the date accordingly. If you want to specify a different format in the Serializer/Deserializer, you'll have to instantiate it with your custom java.time.format.DateTimeFormatter
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.