Clojure parse timestamp to string

1.1k Views Asked by At

I am trying to convert a clojure timestamp to a specific format. I am using the clj-time library. https://github.com/clj-time/clj-time. Here is what I am doing:

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

Which looks a lot like the documentation example, but I don't understand why I got a ClassCastException looking like that:

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

Thanks for your help.

1

There are 1 best solutions below

0
romain-nio On BEST ANSWER

define a parser :

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

then use it:

(fmt/unparse custom-formatter (time/date-time 2010 10 3))