Java Utility Library

Java UUID - getLeastSignificantBits() Method



The java.util.UUID.getLeastSignificantBits() method returns the least significant 64 bits of this UUID's 128 bit value.

Syntax

public long getLeastSignificantBits()

Parameters

No parameter is required.

Return Value

Returns the least significant 64 bits of this UUID's 128 bit value.

Exception

NA.

Example:

In the example below, the java.util.UUID.getLeastSignificantBits() method returns the least significant 64 bits of the given UUID's 128 bit value.

import java.util.*;

public class MyClass {
  public static void main(String[] args) {
    //creating an UUID
    UUID uid = UUID.fromString("d81e4f2e-cdf2-10e6-529b-7df92533d1cb");

    //printing least significant bits
    System.out.println("Least Significant bits: " + uid.getLeastSignificantBits());  
  }
}

The output of the above code will be:

Least Significant bits: 5952489841524724171

❮ Java.util - UUID