Issue with OffsetDateTime deserialization from json request body Spring-Boot REST API

2k views Asked by At

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?

0

There are 0 answers