Created
September 1, 2017 02:26
-
-
Save maxp/d59fd3f05980a65427a8239192543ee3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(import [java.util UUID]) | |
(defn timebased-uuid [] | |
(let [uuid (UUID/randomUUID) | |
time (int (/ (System/currentTimeMillis) 1000)) | |
high (.getMostSignificantBits uuid)] | |
(UUID. | |
(bit-or | |
(bit-and high 0x00000000FFFFFFFF) | |
(bit-shift-left time 32)) | |
(.getLeastSignificantBits uuid)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment