Skip to content

Default conversion for $date type should be Instant #4864

Closed as not planned
Closed as not planned
@mikeyg123

Description

@mikeyg123

When deserialising to a Map or similar flexible type $date fields get deserialised as java.util.date
e.g: something like
mongoTemplate.find(query, Map.class, "myCollection")
will convert:

  {"time": {
    "$date": "2024-10-18T16:32:51.058Z"
  }}

returning a Date for the "time" field.
java.util.Date is an antiquated, broken and difficult to use class. Since timezone ('z') information is specified in the value the natural default conversion would be java.time.Instant. (or possibly a ZonedDateTime but this is possibly less convenient in the majority of cases)
In general all uses of java.util.Date and java.util.Calendar should be removed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: feedback-reminderWe've sent a reminder that we need additional information before we can continuestatus: waiting-for-feedbackWe need additional information before we can continue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions