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

why not to support java.time.Datetime in jdk8? #177

Open
liewhite opened this issue Oct 21, 2018 · 2 comments
Open

why not to support java.time.Datetime in jdk8? #177

liewhite opened this issue Oct 21, 2018 · 2 comments

Comments

@liewhite
Copy link

No description provided.

@michaelklishin
Copy link
Owner

Monger predates JDK 8. Contributions are welcome.

@maxp
Copy link

maxp commented Apr 28, 2019

I use code like this for java.time

(extend-protocol ConvertToDBObject
  LocalDateTime
  (to-db-object [input]
    (to-db-object (Date/from (.toInstant input (ZoneId/systemDefault)))))
  ZonedDateTime
  (to-db-object [input]
    (to-db-object (Date/from (.toInstant input (ZoneId/systemDefault))))))

(extend-protocol ConvertFromDBObject
  java.util.Date
  (from-db-object [^java.util.Date input keywordize]
    (java.time.LocalDateTime/ofInstant (.toInstant input) (ZoneId/systemDefault))))
  

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

No branches or pull requests

3 participants