@Test
  public void javaUtilDate() throws IOException {
    Date now = new Date();
    long epoch = now.getTime();

    TypeAdapter<Date> adapter = gson.getAdapter(Date.class);

    // read
    Date date = adapter.read(Jsons.readerAt(new BsonDateTime(epoch)));
    check(date).is(now);

    // write
    BsonValue bson = writeAndReadBson(now);
    check(bson.getBsonType()).is(BsonType.DATE_TIME);
    check(new Date(bson.asDateTime().getValue())).is(now);
  }
Tests that {@code java.time.*} and {@link Date} BSON codecs are properly working with Gson type adapters.
mongo/test/org/immutables/mongo/bson4gson/JavaTimeTest.java