1
使用clj-time庫來解析Clojure時間如#inst "2017-01-01T12:00:00"
到Joda時間的正確方法是什麼?將Clojure #inst即時轉換爲Joda時間,並使用clj-time
使用clj-time庫來解析Clojure時間如#inst "2017-01-01T12:00:00"
到Joda時間的正確方法是什麼?將Clojure #inst即時轉換爲Joda時間,並使用clj-time
如果你有java.util.Date
對象:
(type #inst "2017-01-01T12:00:00+02:00")
;;=> java.util.Date
clj-time
有clj-time.coerce
命名空間與from-date
函數,它java.util.Date
對象作爲輸入。例如:
(require '[clj-time.coerce :as c])
((juxt type str) (c/from-date #inst "2017-01-01T12:00:00"))
;;=> [org.joda.time.DateTime "2017-01-01T12:00:00.000Z"]