Today We are Going To Solve JSON parse error: Cannot deserialize value of type `java.time.LocalDateTime` from String in Java. Here we will Discuss All Possible Solutions and How this error Occurs So let’s get started with this Article.
Contents
How to Fix JSON parse error: Cannot deserialize value of type `java.time.LocalDateTime` from String Error?
- How to Fix JSON parse error: Cannot deserialize value of type `java.time.LocalDateTime` from String Error?
To Fix JSON parse error: Cannot deserialize value of type `java.time.LocalDateTime` from String Error just Use the “yyyy-MM-dd'T'HH:mm:ss.SSS” format. You should use the “yyyy-MM-dd'T'HH:mm:ss.SSS” format to solve this error. So just use it like below
@JsonFormat(shape=JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss[.SSS][.SS][.S]") private LocalDateTime updatedTime;
- JSON parse error: Cannot deserialize value of type `java.time.LocalDateTime` from String
To Fix JSON parse error: Cannot deserialize value of type `java.time.LocalDateTime` from String Error just Use the below code. You can use the below one code to solve this error
@JsonDeserialize(using = LocalDateTimeDeserializer.class) @JsonSerialize(using = LocalDateTimeSerializer.class) private LocalDateTime pickupDate;
Solution 1 : Use the “yyyy-MM-dd’T’HH:mm:ss.SSS” format
You should use the “yyyy-MM-dd’T’HH:mm:ss.SSS” format to solve this error. So just use it like below
@JsonFormat(shape=JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss[.SSS][.SS][.S]")
private LocalDateTime updatedTime;
Solution 2 : Use the below code
You can use the below one code to solve this error
@JsonDeserialize(using = LocalDateTimeDeserializer.class)
@JsonSerialize(using = LocalDateTimeSerializer.class)
private LocalDateTime pickupDate;
Conclusion
So these were all possible solutions to this error. I hope your error has been solved by this article. In the comments, tell us which solution worked? If you liked our article, please share it on your social media and comment on your suggestions. Thank you.
Also Read These Solutions
- Cannot open local file – Chrome: Not allowed to load local resource
- OpenCV(4.1.2) error: (-215:Assertion failed) !ssize.empty() in function ‘cv::resize’
- OpenSSL Error messages: error:1416F086:SSL routines:tls_process_server_certificate:certificate verify failed
- ESLint: Component definition is missing displayName (react/display-name)
- “IsADirectoryError: [Errno 21] Is a directory: It is a file”