Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
exception handling example
(ns my-ns
(:use [clj-time.core :only [date-time]]))
(defn my-date-time
"same as clj-time.core date-time but returns nil on improper input"
[& args]
(try
(apply date-time (map #(Integer/parseInt %) args))
(catch RuntimeException e nil)))
; returns a clj-time.core date-time
(println (my-date-time "2011" "01" "01"))
; returns nil
(println (my-date-time "2011" "asdf" "01"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.