Closed nimo23 closed 3 years ago
Hi, @nimo23
Both use System.currentTimeMillis()
to get the current time.
The time-based UUID simulates high precision clock by adding a value between 0 and 9,999 to the timestamp. The RFC-4122 suggests the following in the section 4.2.1.2:
A high resolution timestamp can be simulated by keeping a count of
the number of UUIDs that have been generated with the same value of
the system time, and using it to construct the low order bits of the
timestamp. The count will range between zero and the number of
100-nanosecond intervals per system time interval.
The lib uuid-creator
used a counter until the version 3.2.0. Now it uses an accumulator (commits 2d7d6cf4067eebd0c5a017168a84671bed23cc12 and 79af4e6797da9a066e7e237f8779ed3f1d8c61e6).
These are the steps to generate a UUID timestamp:
System.currentTimeMillis()
;Thanks for the explanation. So for high precision time based ID's, the timebased UUID is still the best;)
I have a question: I generated an ulid and an timebased uuid to a string. When extracting the time from it, the timebased uuid seems more precise:
Why is timebased uuid more precise than ulid?