Generating version 1 UUIDs

uuid-datepath-idmapper does not itself generate version 1 UUIDs. It doesn't need to: it takes a version 1 UUID as an input argument and provides a path as the return value.

However, the Java Class Library provided UUID class only generates version 4 UUIDs, so what follows is a brief overview of some options to generate the version 1 UUIDs that uuid-datepath-idmapper expects.

Java Uuid Generator (JUG)

JUG is what uuid-datepath-idmapper uses internally for parsing version 1 uuids. It also supports generating version 1 UUIDs.

  EthernetAddress addr = EthernetAddress.fromInterface();
  TimeBasedGenerator uuidGenerator = Generators.timeBasedGenerator(addr);
  UUID uuid = uuidGenerator.generate();

The test sources contain an example of how you might extend JUG to support taking an arbitrary timestamp (rather than using the current system time).

com.eaio.uuid.UUID

com.eaio.uuid.UUID generates only type 1 UUIDs.

com.eaio.uuid.UUID has two constructors for generating new UUIDs. The default constructor creates a new type 1 UUID based on the current system time and MAC address of the host. An alternative constructor takes two long arguments, time and clockSeqAndNode.

  UUID u = new UUID();
  UUID u = new UUID(4242L, 4242L);