本文整理匯總了Java中java.util.UUID.timestamp方法的典型用法代碼示例。如果您正苦於以下問題:Java UUID.timestamp方法的具體用法?Java UUID.timestamp怎麽用?Java UUID.timestamp使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.util.UUID
的用法示例。
在下文中一共展示了UUID.timestamp方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getTimeFromUUID
import java.util.UUID; //導入方法依賴的package包/類
private static long getTimeFromUUID(UUID uuid) {
return (uuid.timestamp() - NUM_100NS_INTERVALS_SINCE_UUID_EPOCH) / 10000;
}
示例2: unixTimestamp
import java.util.UUID; //導入方法依賴的package包/類
/**
* @param uuid
* @return milliseconds since Unix epoch
*/
public static long unixTimestamp(UUID uuid)
{
return (uuid.timestamp() / 10000) + START_EPOCH;
}
示例3: microsTimestamp
import java.util.UUID; //導入方法依賴的package包/類
/**
* @param uuid
* @return microseconds since Unix epoch
*/
public static long microsTimestamp(UUID uuid)
{
return (uuid.timestamp() / 10) + START_EPOCH * 1000;
}
示例4: getAdjustedTimestamp
import java.util.UUID; //導入方法依賴的package包/類
/**
* 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;
}