{
"toDepartureDate": "2016-12-28",
"fromDepartureDate": "2016-12-28"
}
Run Code Online (Sandbox Code Playgroud)
我想将上面的字符串日期以 json 格式发布java.time.LocalDate,但我收到 400 Bad Request 作为错误。有人可以帮忙吗?我已经使用过@JsonFormat,但它也没有帮助我。
@JsonFormat(shape=JsonFormat.Shape.STRING,pattern="yyyy-MM-dd",timezone = "GMT+5:30")
private LocalDate fromDepartureDate;
@JsonFormat(shape=JsonFormat.Shape.STRING,pattern="yyyy-MM-dd",timezone = "GMT+5:30")
private LocalDate toDepartureDate;
{
"timestamp": 1482942147246,
"status": 400,
"error": "Bad Request",
"exception": "org.springframework.validation.BindException",
"errors": [
{
"codes": [
"typeMismatch.flightReportSearchDto.fromDepartureDate",
"typeMismatch.fromDepartureDate",
"typeMismatch.java.time.LocalDate",
"typeMismatch"
],
"arguments": [
{
"codes": [
"flightReportSearchDto.fromDepartureDate",
"fromDepartureDate"
],
"arguments": null,
"defaultMessage": "fromDepartureDate",
"code": "fromDepartureDate"
}
],
"defaultMessage": "Failed to convert property value of type [java.lang.String] to required type [java.time.LocalDate] for property …Run Code Online (Sandbox Code Playgroud)