Skip to content

Instantly share code, notes, and snippets.

@rwat
Created January 24, 2011 15:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rwat/793340 to your computer and use it in GitHub Desktop.
Save rwat/793340 to your computer and use it in GitHub Desktop.
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