A timestamp is an object that does not have a โformatโ. You can choose the format as text yourself or use, for example. cheshire to create JSON. Cheshire knows which date format is suitable for JSON and can do the conversion.
user> (def x (java.util.Date.))
Clojure printer knows how to present binary objects to people:
user> x #inst "2015-02-13T06:24:09.629-00:00" user> (pr-str x) "#inst \"2015-02-13T06:24:09.629-00:00\""
You can choose the text view yourself:
user> (str x) "Fri Feb 13 08:24:09 EET 2015" ; default format of java.util.Date user> (.format (java.text.SimpleDateFormat. "yyyy-MM-dd'T'HH:mm:ss.SSSXXX") x) "2015-02-13T08:24:09.629+02:00"
Just to make the difference understandable, an object can also be represented as byte values, without loss:
user> (def outs (java.io.ByteArrayOutputStream.)) #'user/outs user> (doto (java.io.ObjectOutputStream. outs) (.writeObject x) (.close)) #<ObjectOutputStream java.io.ObjectOutputStream@2bd682ed > user> (seq (.toByteArray outs)) (-84 -19 0 5 115 114 0 14 106 97 118 97 46 117 116 105 108 46 68 97 116 101 104 106 -127 1 75 89 116 25 3 0 0 120 112 119 8 0 0 1 75 -127 -101 -39 -99 120)
source share