Java – How to generate TimeUUID in Java/Scala


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!

Best Solution

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();