Java Code Examples for java.util.UUID.timestamp()

The following are Jave code examples for showing how to use timestamp() of the java.util.UUID class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: burp-uuid   File: UuidIssue.java   View Source Code Vote up 5 votes
private static long getTimeFromUUID(UUID uuid) {
	return (uuid.timestamp() - NUM_100NS_INTERVALS_SINCE_UUID_EPOCH) / 10000;
}
 
Example 2
Project: sstable-adaptor   File: UUIDGen.java   View Source Code Vote up 4 votes
/**
 * @param uuid
 * @return milliseconds since Unix epoch
 */
public static long unixTimestamp(UUID uuid)
{
    return (uuid.timestamp() / 10000) + START_EPOCH;
}
 
Example 3
Project: sstable-adaptor   File: UUIDGen.java   View Source Code Vote up 4 votes
/**
 * @param uuid
 * @return microseconds since Unix epoch
 */
public static long microsTimestamp(UUID uuid)
{
    return (uuid.timestamp() / 10) + START_EPOCH * 1000;
}
 
Example 4
Project: sstable-adaptor   File: UUIDGen.java   View Source Code Vote up 4 votes
/**
 * Returns a milliseconds-since-epoch value for a type-1 UUID.
 *
 * @param uuid a type-1 (time-based) UUID
 * @return the number of milliseconds since the unix epoch
 * @throws IllegalArgumentException if the UUID is not version 1
 */
public static long getAdjustedTimestamp(UUID uuid)
{
    if (uuid.version() != 1)
        throw new IllegalArgumentException("incompatible with uuid version: "+uuid.version());
    return (uuid.timestamp() / 10000) + START_EPOCH;
}