This format seems correct, but we still have the $date field — let's see how to get rid of it using a custom converter.

5. Custom BSON to JSON Date Conversion

First, we have to implement the BSON Converter interface for type Long, as date values are expressed in milliseconds since epoch time. We're using DateTimeFormatter.ISO_INSTANT to get the expected output format: