Clojure:日期操作方法

;; 日期格式转换
(def df (java.text.SimpleDateFormat. "yyyy-MM-dd hh:mm:ss"))

;; 字符串转换到日期
(defn string-to-datetime [string]
  (.parse df (str string)))

;; 日期转换到字符串
(defn datetime-to-string [datetime]
  (.format (java.text.SimpleDateFormat. "yyyy-MM-dd hh:mm:ss")
            datetime))

;; 获取当前日期
(def now (java.util.Date.))

;; 获取当前日期的字符串形式
(def string-now
  (datetime-to-string now))
原文地址:https://www.cnblogs.com/ilovewindy/p/3837909.html