Skip to content

Instantly share code, notes, and snippets.

@mwmitchell
Created April 16, 2013 00:51
Show Gist options
  • Save mwmitchell/5392520 to your computer and use it in GitHub Desktop.
Save mwmitchell/5392520 to your computer and use it in GitHub Desktop.
(:import [java.util UUID])
(defn uuid->long [uuid]
(if (string? uuid)
(try (when-let [x (UUID/fromString uuid)] (uuid->long x))
(catch Exception e nil))
(bit-xor (.getLeastSignificantBits uuid) (.getMostSignificantBits uuid))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment