Skip to content

Instantly share code, notes, and snippets.

@kmila
Created March 5, 2019 14:09
Show Gist options
  • Save kmila/07a732ea08af45ca70b1bf4af165b2c7 to your computer and use it in GitHub Desktop.
Save kmila/07a732ea08af45ca70b1bf4af165b2c7 to your computer and use it in GitHub Desktop.
public static UUID sequentialId(int id) {
Assert.isTrue(id >= 0, "[Assertion failed] - negative id");
return UUID.fromString(String.format("%08d-%04d-%04d-%04d-%012d", Math.min(id, 99999999), 0, 0, 0, 0));
}
public static String asString(UUID uuid) {
return String.format("%016x", uuid.getMostSignificantBits());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment