Skip to content

Instantly share code, notes, and snippets.

@cbianco
cbianco / UUIDV7.java
Last active October 7, 2025 16:32
Basic UUID v7 implementation following RFC 9562
import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import java.util.concurrent.ThreadLocalRandom;
/**
* A UUID v7 implementation following RFC 9562.
* <p>
* UUID v7 features a time-ordered value field derived from the widely implemented Unix Epoch
* timestamp source, providing improved database locality and performance compared to random UUIDs
* (v4).