2

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.

Jason Aller
  • 3,541
  • 28
  • 38
  • 38
Elie Ladias
  • 111
  • 2
  • 16

1 Answers1

4

define a parser :

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

then use it:

(fmt/unparse custom-formatter (time/date-time 2010 10 3))
romain-nio
  • 1,183
  • 9
  • 25