Search code examples
javadatetimeclojure

What is the best way to get date and time in Clojure?


I need to log some events on a Clojure Client-Server scenario, but it seems to me that Clojure does not provide a date/time function. Can any one confirm this or I am missing something here?! If I am correct then I need to use java interop, right?


Solution

  • If all you need is to get the current time and date for your logger, then this function is OK:

     (defn now [] (new java.util.Date))
    

    Now that you mentioned this, it would be useful to have support for immutable Date objects.