Cassandra has a timeuuid type, and there are functions to create a timeuuid for "now". There's also documented ways of getting back the time from a timeuuid. However, is there a way to get a timeuuid from a joda DateTime? It feels like this should exist.
Asked
Active
Viewed 515 times
1 Answers
1
Check out the UUIDGen class. It looks like you could use the following to generate a UUID from a DateTime (using the getMillis() method).
DateTime someDateTime = ...;
UUID timeUUID = UUIDGen.getTimeUUID(someDateTime.getMillis());

Christopher Bradford
- 2,220
- 2
- 15
- 12
-
That seems to be part of Cassandra itself, rather than in the client library. – ashic Dec 01 '16 at 16:32
-
If you prefer client based code there is a [UUIDs](https://github.com/datastax/java-driver/blob/3.x/driver-core/src/main/java/com/datastax/driver/core/utils/UUIDs.java#L229-L275) class as part of the java driver. See [UUIDs.startOf()](http://docs.datastax.com/en/drivers/java-dse/1.1/com/datastax/driver/core/utils/UUIDs.html#startOf-long-) and [UUIDs.endOf()](http://docs.datastax.com/en/drivers/java-dse/1.1/com/datastax/driver/core/utils/UUIDs.html#endOf-long-). Convert the Joda DateTime to milliseconds. – Christopher Bradford Dec 01 '16 at 21:49