How to generate time based UUIDs?

java, uuid

Solution

FasterXML Java Uuid Generator (JUG)

https://github.com/cowtowncoder/java-uuid-generator

UUID uuid = Generators.timeBasedGenerator().generate();

Problem

I want to generate time-based universally unique identifier (UUID) in Java. The method `java.util.UUID.randomUUID()` generates a UUID Version 4 where 122 of the 128 bits are from a cryptographically-strong random number generator. How to generate a Version 1 (time based) UUID ? Is there a separate library for that or is it some how provided in the Java 7 API and I am missing it.

Original source