I have a class as follows:
public class InstantWrapper {
@JsonFormat(without = Feature.WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS)
private Instant myInstant;
public Instant getMyInstant() { return myInstant; }
public void setMyInstant(Instant myInstant) { this.myInstant = myInstant; }
}
When serialising, the result uses milliseconds since the epoch; however, when deserialising, it is interpreted as nanoseconds.
I understand that the JavaDoc says "Override for SerializationFeature.WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS" (saying nothing about DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS), however in my view it's undesirable that a round-trip modifies the data when this option is used.
Is there a way (other than writing my own deserialiser) to override the ObjectMapper's settings so that timestamps are interpreted using milliseconds?