I have the field initiationDate which serialises by ToStringSerializer class to ISO-8601 format.
@JsonSerialize(using = ToStringSerializer.class)
private LocalDateTime initiationDate;
When I receive the following JSON,
...
"initiationDate": "2016-05-11T17:32:20.897",
...
I want to deserialize it by LocalDateTime.parse(CharSequence text) factory method. All my attempts ended with com.fasterxml.jackson.databind.JsonMappingException:
Can not instantiate value of type [simple type, class
java.time.LocalDateTime] fromStringvalue ('2016-05-11T17:32:20.897'); no single-Stringconstructor/factory method
How do I achieve that? How can I specify factory method?
EDIT:
The problem has been solved by including jackson-datatype-jsr310 module to the project and using @JsonDeserialize with LocalDateTimeDeserializer.
@JsonSerialize(using = ToStringSerializer.class)
@JsonDeserialize(using = LocalDateTimeDeserializer.class)
private LocalDateTime initiationDate;