ebl ebl - 5 months ago 37x
Java Question

How to covert time based java.util.UUID to DateTIme

I'm using

to generate time based UUID but i can't convert the it back to date time:

I tried using
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


As you can see from UUIDJavaDoc, 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 .