Java Utility Library

Java UUID - clockSequence() Method



The java.util.UUID.clockSequence() method returns the clock sequence value associated with this UUID. The clockSequence value is only meaningful in a time-based UUID, which has version type 1. If this UUID is not a time-based UUID then this method throws UnsupportedOperationException.

Syntax

public int clockSequence()

Parameters

No parameter is required.

Return Value

Returns clock sequence of this UUID.

Exception

Throws UnsupportedOperationException, if this UUID is not a version 1 UUID.

Example:

In the example below, the java.util.UUID.clockSequence() method returns the clock sequence value associated with the given UUID.

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 the clock sequence value of the uuid
    System.out.println("ClockSequence Value: " + uid.clockSequence());  
  }
}

The output of the above code will be:

ClockSequence Value: 4763

❮ Java.util - UUID