On 27/04/2026 03:04, Jaikiran Pai wrote:
Hello David,
On 27/04/26 7:21 am, David Alayachew wrote:
Hello @core-libs-dev <[email protected]>,
Today was the first time I used the UUID library past
UUID.randomUUID() and
UUID.fromString(String).
I saw that UUID.ofEpochMillis(long timestamp) has the ability to
create a
UUID version 7 UUID -- a time-based UUID! Great, I also see that
there is a
UUID.timestamp() method, can I use that to extract the timestamp from
it?
Sadly, no. The UUID.timestamp() method is reserved for UUID version 1,
whereas UUID.ofEpochMillis(long timestamp) generates UUID version 7.
Ok, fair, the documentation is clear. But why can't we just add that
functionality to UUID.timestamp()? It's not that complex.
This and other similar questions were discussed during the review of
https://bugs.openjdk.org/browse/JDK-8334015. The PR here
https://github.com/openjdk/jdk/pull/25303 (or its corresponding
mailing list thread in core-libs-dev) has all those discussions. For
this specific question, the discussion is here
https://mail.openjdk.org/pipermail/core-libs-dev/2025-September/152621.html
Right, type 1 and 7 have different epochs and granularity so
UUID::timestamp has to throw when not type 1.
A method that returns an Instant could be feasible but would require
working some examples to check for surprises and hazards.
-Alan