Last active
May 29, 2023 19:35
-
-
Save LeeSanghoon/5811136 to your computer and use it in GitHub Desktop.
Generate short UUID
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.nio.ByteBuffer; | |
import java.util.UUID; | |
/** | |
* Generate short UUID (13 characters) | |
* | |
* @return short UUID | |
*/ | |
public static String shortUUID() { | |
UUID uuid = UUID.randomUUID(); | |
long l = ByteBuffer.wrap(uuid.toString().getBytes()).getLong(); | |
return Long.toString(l, Character.MAX_RADIX); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
As a one-liner: