javascalauuid

Create UUID with zeros


I'm trying to generate a UUID with all zeros:

java.util.UUID fromString "00000000-00000000-00000000-00000000"

The error is

 java.lang.IllegalArgumentException: Invalid UUID string: 00000000-00000000-00000000-00000000
    at java.util.UUID.fromString(UUID.java:194)

What am I doing wrong?

I want to create either "MinValue" or "Invalid" UUID.


Solution

  • try this

    System.out.println(new UUID(0,0));
    

    it prints

    00000000-0000-0000-0000-000000000000
    

    this is the right format to use in UUID.fromString