JSON { public static String toJSON(@Nullable Object instance) { try { return OBJECT_MAPPER.writeValueAsString(instance); } catch (IOException e) { throw new UncheckedIOException(e); } }  @Nullable static T fromJSON(Type instanceType, String json); @Nullable static T fromJSON(Class<T> instanceClass, String json); static String toJSON(@Nullable Object instance); static T fromEnumValue(Class<T> valueClass, String jsonValue); static String toEnumValue(T value);  }
@Test void nanoFractionOfDateField() { assertThat(JSON.toJSON(LocalDateTime.of(2019, 4, 25, 1, 0, 0, 200000000))) .isEqualTo("\"2019-04-25T01:00:00.200\""); assertThat(JSON.toJSON(LocalDateTime.of(2019, 4, 25, 1, 0, 0, 0))) .isEqualTo("\"2019-04-25T01:00:00.000\""); assertThat(JSON.toJSON(ZonedDateTime.of(2019, 4, 25, 1, 0, 0, 200000000, ZoneId.of("UTC")))) .isEqualTo("\"2019-04-25T01:00:00.200Z\""); assertThat(JSON.toJSON(ZonedDateTime.of(2019, 4, 25, 1, 0, 0, 0, ZoneId.of("UTC")))) .isEqualTo("\"2019-04-25T01:00:00Z\""); assertThat(JSON.toJSON(ZonedDateTime.of(2019, 4, 25, 1, 0, 0, 0, ZoneId.of("America/New_York")))) .isEqualTo("\"2019-04-25T05:00:00Z\""); assertThat(JSON.toJSON(LocalTime.of(18, 0))) .isEqualTo("\"18:00:00.000\""); assertThat(JSON.toJSON(LocalTime.of(18, 1, 2, 200000000))) .isEqualTo("\"18:01:02.200\""); assertThat(JSON.toJSON(LocalTime.of(18, 1, 2, 123456789))) .isEqualTo("\"18:01:02.123456789\""); }