2

我正在尝试将 clojure 时间戳转换为特定格式。我正在使用 clj-time 库。https://github.com/clj-time/clj-time。这是我正在做的事情:

(f/unparse :year-month-day  (t/date-time 2010 10 3))

这看起来很像文档示例,但我不明白为什么我的 ClassCastException 看起来像这样:

ClassCastException clojure.lang.Keyword cannot be cast to org.joda.time.format.DateTimeFormatter  clj-time.format/unparse (format.clj:185)

谢谢你的帮助。

4

1 回答 1

4

定义一个解析器:

 (def custom-formatter (fmt/formatter "yyyy-MM-dd"))

然后使用它:

(fmt/unparse custom-formatter (time/date-time 2010 10 3))
于 2014-09-05T09:02:57.597 回答