本文整理匯總了Java中java.util.UUID.version方法的典型用法代碼示例。如果您正苦於以下問題:Java UUID.version方法的具體用法?Java UUID.version怎麽用?Java UUID.version使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.util.UUID
的用法示例。
在下文中一共展示了UUID.version方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: UuidIssue
import java.util.UUID; //導入方法依賴的package包/類
public UuidIssue(IHttpRequestResponse baseRequestResponse,
URL url, UUID uuid) throws IllegalArgumentException {
httpMessages = new IHttpRequestResponse[] { baseRequestResponse };
this.url = url;
this.uuid = uuid;
isV1or2 = uuid.version() < 3;
}
示例2: fromTimeUUID
import java.util.UUID; //導入方法依賴的package包/類
public static String fromTimeUUID(UUID src) {
if (src.version() != 1) {
throw new IllegalArgumentException("Not a time UUID!");
}
String str = src.toString();
return str.substring(15, 18) + str.substring(9, 13) + str.substring(0, 8) + str.substring(19, 23)
+ str.substring(24);
}
示例3: 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;
}