@Before
  public void setUp() {
    TypeAdapter<Date> dateTypeAdapter = GsonCodecs.typeAdapterFromCodec(new DateCodec());
    gson = GsonCodecs.newGsonWithBsonSupport(
            new GsonBuilder().registerTypeAdapter(Date.class, dateTypeAdapter).create()
    );
  }
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