@Override
    public void serialize(Date value, JsonGenerator gen, SerializerProvider provider) throws IOException {
      final BsonWriter writer = ((BsonGenerator) gen).unwrap();
      writer.writeDateTime(value.getTime());
    }
Custom serializer to test {@link BsonType#DATE_TIME} in BSON
mongo/test/org/immutables/mongo/fixture/JacksonRepoTest.java