UUID是128位值。 Java中UUID类的getLeastSignificantBits()方法用于获取此UUID的最低有效64位。
用法:
public long getLeastSignificantBits()
参数:该方法不带任何参数。
返回值:该方法返回一个整数值,该值是此128个值的UUID的最低有效64位。
以下示例程序旨在说明getLeastSignificantBits()方法的用法:
示例1:
// Java code to illustrate
// getLeastSignificantBits() method
import java.util.*;
public class UUID_Demo {
public static void main(String[] args)
{
// Creating two UUIDs
UUID UUID_1
= UUID
.fromString(
"58e0a7d7-eebc-11d8-9669-0800200c9a66");
// Displaying the UUID
System.out.println("UUID: "
+ UUID_1);
// Displaying the value of UUID
System.out.println("The value is: "
+ UUID_1.clockSequence());
// Getting the least significant 64 bit
System.out.println("The least significant 64 bit: "
+ UUID_1
.getLeastSignificantBits());
}
}
输出:
UUID: 58e0a7d7-eebc-11d8-9669-0800200c9a66 The value is: 5737 The least significant 64 bit: -7608541298835023258
示例2:
// Java code to illustrate
// getLeastSignificantBits() method
import java.util.*;
public class UUID_Demo {
public static void main(String[] args)
{
// Creating two UUIDs
UUID UUID_1
= UUID
.fromString(
"58e0a7d7-eebc-11d8-9669-0800200c9a66");
// Displaying the UUID
System.out.println("UUID: "
+ UUID_1);
// Displaying the value of UUID
System.out.println("The value is: "
+ UUID_1.clockSequence());
// Getting the least significant 64 bit
System.out.println("The least significant 64 bit: "
+ UUID_1.getLeastSignificantBits());
}
}
输出:
UUID: 58e0a7d7-eebc-11d8-9669-0800200c9a66 The value is: 5737 The least significant 64 bit: -7608541298835023258
相关用法
- Java UUID compareTo()用法及代码示例
- Java UUID fromString()用法及代码示例
- Java UUID equals()用法及代码示例
- Java UUID getMostSignificantBits()用法及代码示例
- Java UUID clockSequence()用法及代码示例
- Java UUID timestamp()用法及代码示例
- Java UUID hashCode()用法及代码示例
- Java UUID node()用法及代码示例
- Java UUID nameUUIDFromBytes()用法及代码示例
- Java UUID version()用法及代码示例
- Java UUID toString()用法及代码示例
- Java UUID variant()用法及代码示例
- Java Java lang.Long.numberOfLeadingZeros()用法及代码示例
- Java Java lang.Long.reverse()用法及代码示例
注:本文由纯净天空筛选整理自Chinmoy Lenka大神的英文原创作品 UUID getLeastSignificantBits() Method in Java with Examples。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。