I am having an issue with MongoDB 4.x and greater - I suspect this is due to moving from strict to relaxed mode for toJson call.
In summary when retrieving data from MongoDB and converting Document to json using document.toJson(), the conversion to date time string is inconsistent.
Conversion to ISODateTime format is different if time values is rounded to seconds or milliseconds.
In my opinion the first example should convert to
ISODateTimeFormat like Joda Time’s ISODateTimeFormatter.dateTime will fail trying to parse example 1.
Any suggestions on how to ensure output format is always the same - i.e., in example above
BsonDateTime(1596118502000L) should convert to
I suspect this can be done by setting JsonWriterSettings in the document.toJson() call but this would have to done with every call with could lead to errors down the road - it would be better to be able to set a default handler to convert to json.