clojure clj-time Adding joda date-time from other time types


The clj-time.coerce library can help converting other date-time formats to joda time format (clj-time.core/date-time). The other formats include Java long format, String, Date, SQL Date.

To convert time from other time formats, include the library and use the from- function, e.g.

(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>