In my Java 8 code I'm trying to format string date to LocalDate format. I am using the LocalDateDeserializer.class. I get the error
com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Cannot construct instance of `java.time.LocalDate` (no Creators, like default construct, exist): no String-argument constructor/factory method to deserialize from String value ('19440912').
Can any one tell me what could be the error?
You need to add the datetime module from jackson-modules-java8 :
Datatype module to make Jackson recognize Java 8 Date & Time API data types (JSR-310).
Register it using:
ObjectMapper mapper = new ObjectMapper();
mapper.registerModule(new JavaTimeModule());
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.