DateTypeConverters { @Nullable @TypeConverter public static OffsetDateTime toOffsetDateTime(@Nullable String sqlValue) { if (sqlValue == null) { return null; } else { return OffsetDateTime.parse(sqlValue, OFFSET_FORMATTER); } } private  DateTypeConverters(); @Nullable @TypeConverter static OffsetDateTime toOffsetDateTime(@Nullable String sqlValue); @Nullable @TypeConverter static String fromOffsetDateTime(@Nullable OffsetDateTime dateTime); @Nullable @TypeConverter static String fromInstant(Instant instant); @Nullable @TypeConverter static Instant toInstant(String value);  }
@Test public void toOffsetDateTime() { OffsetDateTime now = OffsetDateTime.now(); String expected = now.format(DateTypeConverters.OFFSET_FORMATTER); assertEquals(expected, DateTypeConverters.fromOffsetDateTime(now)); }
@Test public void fromOffsetDateTimeNull() { assertNull(DateTypeConverters.toOffsetDateTime(null)); }