Created
April 20, 2015 23:11
-
-
Save KodeSeeker/281590886d348957dc01 to your computer and use it in GitHub Desktop.
Cassandra convert from UID to Date
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void main (String... args){ | |
UUID uid = UUIDs.timeBased(); | |
long time = getTimeFromUUID(uid); | |
Date date = new Date(time); | |
System.out.println(date); | |
} | |
static final long NUM_100NS_INTERVALS_SINCE_UUID_EPOCH = 0x01b21dd213814000L; | |
public static long getTimeFromUUID(UUID uuid) { | |
return (uuid.timestamp() - NUM_100NS_INTERVALS_SINCE_UUID_EPOCH) / 10000; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment