JSON请求Body Spring-boot REST API的OffsetDateTime避难所的问题
我在我的 pojo 中有一个oftsetDateTime
字段:
@NotBlank(message = "startTime cannot be null or empty; ")
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSSXXX")
@JsonSerialize(using = OffsetDateTimeSerializer.class)
private OffsetDateTime startTime;
当我尝试使用此OffsetTime
JSON字段给API的请求主体时,显示避免误差: :解决
[org.springframework.http.converter.HttpMessageNotReadableException:
JSON parse error: Cannot deserialize value of type `java.time.OffsetDateTime`
from String "2020-07-21T12:12:23.000+0200":
Failed to deserialize java.time.OffsetDateTime: (java.time.format.DateTimeParseException)
Text '2020-07-21T12:12:23.000+0200' could not be parsed at index 23;
nested exception is com.fasterxml.jackson.databind.exc.InvalidFormatException:
Cannot deserialize value of type `java.time.OffsetDateTime`
from String "2020-07-21T12:12:23.000+0200":
Failed to deserialize java.time.OffsetDateTime: (java.time.format.DateTimeParseException)
Text '2020-07-21T12:12:23.000+0200' could not be parsed at index 23
我的输入是正确的吗?
I'm having a OffsetDateTime
field in my POJO:
@NotBlank(message = "startTime cannot be null or empty; ")
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSSXXX")
@JsonSerialize(using = OffsetDateTimeSerializer.class)
private OffsetDateTime startTime;
When I try to give the request body for the API with this offsetTime
JSON field, it shows deserialization error:
: Resolved
[org.springframework.http.converter.HttpMessageNotReadableException:
JSON parse error: Cannot deserialize value of type `java.time.OffsetDateTime`
from String "2020-07-21T12:12:23.000+0200":
Failed to deserialize java.time.OffsetDateTime: (java.time.format.DateTimeParseException)
Text '2020-07-21T12:12:23.000+0200' could not be parsed at index 23;
nested exception is com.fasterxml.jackson.databind.exc.InvalidFormatException:
Cannot deserialize value of type `java.time.OffsetDateTime`
from String "2020-07-21T12:12:23.000+0200":
Failed to deserialize java.time.OffsetDateTime: (java.time.format.DateTimeParseException)
Text '2020-07-21T12:12:23.000+0200' could not be parsed at index 23
Is my input correct and how to deserialize this field from JSON?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论