I'd like to store some test data to a file and read it out again in my tests. The data is a sequence of Clojure maps, one property of which is a clj-time (org.joda.time.DateTime) date/time. When I write the value to the file (with spit), it serializes as #<DateTime 2014-10-03T12:57:15.000Z>. When I try to read it back (with slurp), I get:
RuntimeException Unreadable form clojure.lang.Util.runtimeException (Util.java:221)
I guess that isn't surprising since without more information I don't see how it would know how to parse a DateTime. Is there some way to read these values and have them parsed properly or so I have to serialize them as strings and parse them manually when I read them back out?
Clojure comes with a tagged reader for
java.util.Dateone option would be to convert from
org.joda.time.DateTimetojava.util.Datebefore writing to file, and convert back again after reading.