Reputation: 125
I'm using com.datastax.driver.core.utils.UUIDs
to generate time based UUID but i can't convert the it back to date time:
I tried using org.joda.time
but any other package is fine.
new org.joda.time.DateTime(com.datastax.driver.core.utils.UUIDs.timeBased.timestamp) // 4328915-05-22T15:34:30.000+00:00
new org.joda.time.DateTime() //2015-06-25T13:28:07.249+00:00
Upvotes: 1
Views: 1482
Reputation: 704
As you can see from UUID
JavaDoc, the resulting timestamp is measured in 100-nanosecond units since midnight, October 15, 1582 UTC.
org.joda.time.DateTime(long instant)
expects a timestamp in milliseconds since 1970-01-01T00:00:00Z, see JavaDoc .
Upvotes: 1