Created
March 8, 2019 15:45
-
-
Save regis-leray/9ceae8309e76846358f84a7870483b4f to your computer and use it in GitHub Desktop.
shortId
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
def shortId(id: UUID, length: Int = 10): String = { | |
(id.toString.reverse.take(Math.floor(length/2).toInt) + "-" + UUID.randomUUID().toString.reverse.take(Math.ceil(length/2).toInt)).toUpperCase | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment