The date and time classes built into Java are a horrible mess. What are Clojure programmers to do? Use Joda Time instead. Joda Time is coherently designed and easy to use.
JDBC (at least, the PostgreSQL driver) can’t use Joda Time directly (without explicit type mapping). One way to convert a Joda LocalDate into something JDBC can use:
(defn to-sql-date [date] "Convert any Joda-readable date object (including a string) to a java.sql.Date" (java.sql.Date. (.. (LocalDate. date) toDateMidnight toInstant getMillis)))
It’s not pretty, but it works. You can follow a similar procedure for any of the Joda classes.
Popularity: 30% [?]
If you like this post and would like to receive updates from this blog, please subscribe our feed.

March 25th, 2010 at 2:55 AM
You might want to look at this: http://github.com/clj-sys/clj-time or the incanter chrono lib.
March 25th, 2010 at 2:39 PM
Very nice.. Thanks!