How to generate TimeUUID in Java/Scala

Avis picture Avis · Jul 25, 2014 · Viewed 19.9k times · Source

Does anyone know how to generate TimeBased UUIDs in Java/Scala?

Here is the column family:

CREATE table col(ts timeuuid)

I'm using Cassandra 1.2.4

Appreciate your help!

Answer

Eduardo Dennis picture Eduardo Dennis · Apr 3, 2017

If you are using the Datastax drivers you can use the utility class, UUIDs, to generate one

import com.datastax.driver.core.utils.UUIDs;
....
UUID timeBasedUuid = UUIDs.timeBased();