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

Improve Date storage using Kmongo #362

Open
shpirt opened this issue Aug 12, 2022 · 1 comment
Open

Improve Date storage using Kmongo #362

shpirt opened this issue Aug 12, 2022 · 1 comment

Comments

@shpirt
Copy link

shpirt commented Aug 12, 2022

I tried to use LocalDateTime as attribute type of an entity. After I saved this entity to mongo, the date field was translated to ISO date, which seems "right" in string form, but in fact beyond of actual epoch timestamp by 8 hours(cause my time zone is UTC+8). Was this expected behaviour?

@shpirt shpirt changed the title Storing LocalDateTime using Kmongo Store LocalDateTime using Kmongo Aug 12, 2022
@zigzago zigzago changed the title Store LocalDateTime using Kmongo Improve Date storage using Kmongo Aug 13, 2022
@zigzago
Copy link
Member

zigzago commented Aug 13, 2022

Yes, this is the current expected behaviour. Mongo has no notion of timezone is their date field, so all date types are converted to UTC before serialization and from UTC after deserialization.

I agree that it is not ideal, especially for LocalDateTime, LocalDate & LocalTime. I let this issue open in order to provide an option to:

  • store Local* with the local part in mongo
  • add also a zone storage for ZonedDateTime, OffsetDateTime, etc.

Workaround : just override the serializer & deserializer for the types you use to get the expected behaviour.

See also ZonedDateTime

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants