Skip to content

Add UUIDUtil.extractTimestamp() for extracting 64-bit timestamp for all timestamp-based versions #81

Closed
@gabrielbalan

Description

@gabrielbalan

java.util.UUID#timestamp() only works for version 1 UUIDs.

It would be nice to have similar functionality for version 6 UUIDs.
E.g. a static method in TimeBasedReorderedGenerator, something along the lines of

public static long timestamp(UUID uuid)
{
    assert(uuid.version()==6);
    return ((uuid.getMostSignificantBits()>>>4) & ~0xFFF) | (uuid.getMostSignificantBits()&0xFFF);
}

Better yet, a static method in UUIDUtil that returns the number of millis since unix epoch for versions 1, 6 and 7 UUIDs.

thank you very much
Gabriel

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions