Зачем вообще аннотировать форматы и сериализаторы?
Джексон сделает это автоматически, если вы зарегистрируете модуль JSR310.
Proof
public class A {
@JsonProperty private String name;
@JsonProperty private LocalDate date1;
@JsonProperty private LocalDate date2;
@JsonProperty private LocalDate rdate3;
public A() {
}
public A(String name, LocalDate date1, LocalDate date2, LocalDate rdate3) {
this.name = name;
this.date1 = date1;
this.date2 = date2;
this.rdate3 = rdate3;
}
@Override
public String toString() {
return "A [name=" + this.name + ", date1=" + this.date1 +
", date2=" + this.date2 + ", rdate3=" + this.rdate3 + "]";
}
}
ObjectMapper mapper = new ObjectMapper()
.registerModule(new JavaTimeModule()) // or: .findAndRegisterModules()
.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false)
;
A a = new A("Foo", LocalDate.of(2000, 1, 1), LocalDate.now(), LocalDate.of(2999, 12, 31));
System.out.println(a);
String json = mapper.writeValueAsString(a);
System.out.println(json);
A a2 = mapper.readValue(json, A.class);
System.out.println(a2);
Выход
A [name=Foo, date1=2000-01-01, date2=2018-05-01, rdate3=2999-12-31]
{"name":"Foo","date1":"2000-01-01","date2":"2018-05-01","rdate3":"2999-12-31"}
A [name=Foo, date1=2000-01-01, date2=2018-05-01, rdate3=2999-12-31]