Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Default conversion for $date type should be Instant #4864

Open
mikeyg123 opened this issue Dec 24, 2024 · 0 comments
Open

Default conversion for $date type should be Instant #4864

mikeyg123 opened this issue Dec 24, 2024 · 0 comments
Labels
status: waiting-for-triage An issue we've not yet triaged

Comments

@mikeyg123
Copy link

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.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Dec 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: waiting-for-triage An issue we've not yet triaged
Projects
None yet
Development

No branches or pull requests

2 participants