Skip to content

Instantly share code, notes, and snippets.

@regis-leray
Created March 8, 2019 15:45
Show Gist options
  • Save regis-leray/9ceae8309e76846358f84a7870483b4f to your computer and use it in GitHub Desktop.
Save regis-leray/9ceae8309e76846358f84a7870483b4f to your computer and use it in GitHub Desktop.
shortId
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