Document how to go from an instant to a ZonedDateTime
jacobemcken opened this issue · 2 comments
jacobemcken commented
I would assume there would be a "prettier" way to convert an instant to a ZonedDateTime, because it looks clunky using Java interop (ofInstant) like this:
(java.time.ZonedDateTime/ofInstant (java-time/instant "2021-05-16T22:00:00Z") (java-time/zone-id "Europe/Copenhagen"))Is this the "best" way?
dm3 commented
(j/zoned-date-time (j/instant) "UTC") works. Am I missing something in the question?
jacobemcken commented
I think you hit the spot, thanks.
Looking at the documentation for converstions it might be an idea to include the above example.
Since j/zoned-date-time can be called without a zone in both these cases:
(j/zoned-date-time)
(j/zoned-date-time (offset-date-time 2015 9 28 1))I probably assumed I could do it with an instant as well:
(java-time/zoned-date-time (java-time/instant))Instead I got this not so readable exception:
1. Unhandled clojure.lang.ExceptionInfo
Could not convert [#object[java.time.Instant 0x281410c4
"2021-03-23T13:51:48.768Z"]] to class java.time.ZonedDateTime!
...