java get uuid_Java UUID getMostSignificantBits()用法及代码示例

UUID是128位值。 Java中UUID类的getMostSignificantBits()方法用于获取此UUID的最高有效64位。

用法:

public long getMostSignificantBits()

参数:该方法不带任何参数。

返回值:该方法返回一个整数值,该值是此128个值的UUID的最高有效64位。

以下示例程序旨在说明getMostSignificantBits()方法的用法:

示例1:

// Java code to illustrate

// getMostSignificantBits() 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 most significant 64 bit

System.out.println("The most significant 64 bit: "

+ UUID_1

.getMostSignificantBits());

}

}

输出:

UUID: 58e0a7d7-eebc-11d8-9669-0800200c9a66

The value is: 5737

The most significant 64 bit: 6404303215985955288

示例2:

// Java code to illustrate

// getMostSignificantBits() 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 most significant 64 bit

System.out.println("The most significant 64 bit: "

+ UUID_1.getMostSignificantBits());

}

}

输出:

UUID: 58e0a7d7-eebc-11d8-9669-0800200c9a66

The value is: 5737

The most significant 64 bit: 6404303215985955288

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值