從其他時間型別新增 joda 日期時間

clj-time.coerce 庫可以幫助將其他日期時間格式轉換為 joda 時間格式(clj-time.core / date-time)。其他格式包括 Java 長格式,字串日期SQL 日期

要從其他時間格式轉換時間,請包含庫並使用 from-function,例如

(require '[clj-time.coerce :as c])

(def string-time "1990-01-29")
(def epoch-time 633571200)
(def long-time 633551400)

(c/from-string string-time) ;; #<DateTime 1990-01-29T00:00:00.000Z>
(c/from-epoch epoch-time) ;; #<DateTime 1990-01-29T00:00:00.000Z>
(c/from-long 633551400) ;; #<DateTime 1990-01-29T00:00:00.000Z>