Created
January 22, 2020 22:31
-
-
Save aarkerio/61d7a34e869b1c0628be2c753d2ee72e to your computer and use it in GitHub Desktop.
Clojure. Format an Instant
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(:require [java-time :as jt])) | |
(defn format-date | |
"Format a Java instant" | |
[date] | |
(let [formatter (jt/format "dd-MM-yyyy HH:mm")] | |
(jt/format formatter (.atZone date (jt/zone-id))))) | |
;; clj-time is now deprecated |
user> (java-time/format "dd-MM-yyyy HH:mm" (java-time/zoned-date-time #inst "2021-04-20T06:53:03.108042000-00:00" (java-time/zone-id)))
"20-04-2021 06:53"
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I think line 6 should be a call to
jt/formatter
, notjt/format
. I also don't understand the declarative (and as far as I can tell, incorrect) statement that "clj-time is now deprecated". I don't think anyone considers it a community standard lib.