本文整理汇总了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;
}