ashic
ashic

Reputation: 6495

Get timebased UUID from datetime on the jvm

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.

Upvotes: 1

Views: 544

Answers (1)

Christopher Bradford
Christopher Bradford

Reputation: 2260

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

Upvotes: 1

Related Questions