【发布时间】:2018-10-26 08:15:28
【问题描述】:
我有一个 Angular 应用程序,它会向我发送一个日期,例如 dd/MM/yyyy 和 yyyy-MM-dd。 我如何使用@JsonFormat 来接受两种模式? 目前我只是使用:
@Temporal(TemporalType.DATE)
@JsonFormat(pattern="dd/MM/yyyy")
private Date hireDate;
当我收到的日期采用这种格式 dd/MM/yyyyy 但当日期采用这种格式 yyyy-MM-dd 时,我有一个 json 解析错误
org.springframework.http.converter.HttpMessageNotReadableException: JSON parse error: Cannot deserialize value of type `java.util.Date` from String "2018-10-26": expected format "dd/MM/yyyy";
【问题讨论】:
标签: json spring spring-boot spring-data