[英]Spring Boot with Java 8 Date format
I trying to use java 8 LocalDate with springboot 我试图在springboot中使用Java 8 LocalDate
I put 我放
compile ("com.fasterxml.jackson.datatype:jackson-datatype-jsr310")
int .gradle 整数.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 ks
By default, the format accepted by the LocalDateDeserializer
class is yyyy-mm-dd. 默认情况下,
LocalDateDeserializer
类接受的格式为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
如果要在Serializer / Deserializer中指定其他格式,则必须使用自定义
java.time.format.DateTimeFormatter
实例化它
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.