Skip to content

Instantly share code, notes, and snippets.

@davidandrzej
Created October 25, 2012 23:22
Show Gist options
  • Select an option

  • Save davidandrzej/3956097 to your computer and use it in GitHub Desktop.

Select an option

Save davidandrzej/3956097 to your computer and use it in GitHub Desktop.
Simple protocol / record example
(defprotocol Dateable
"Convertible to a Java Date"
(to-date [this] "Convert to Java Date"))
(defrecord TimeMs [timeInMs]
Dateable
(to-date [this] (new Date (long (:timeInMs this)))))
(defrecord TimeOffset [offsetString]
Dateable
(to-date [this]
(new Date (- (System/currentTimeMillis)
(parse-offset-string offsetString)))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment