Site icon

Generate UUID or GUID from String in java (with example)

Program: generate UUID or GUID from String in java

package org.learn.uuid;

import java.util.UUID;

public class GenerateUUIDFromString {
    public static void main(String[] args) {
        //Given Input UUID string
        String inputUUID = "ea33eca1-c704-4062-a111-98f7b323e824";
        System.out.printf("1. Given input string of UUID : %s", inputUUID);

        //Generate UUID from string uuid
        UUID generateUUID = UUID.fromString(inputUUID);
        System.out.printf("\n2. Generate UUID from String (UUID) : %s",
                                                    generateUUID.toString());
    }
}

Output: generate UUID or GUID from String in java

1. Given input string of UUID : ea33eca1-c704-4062-a111-98f7b323e824
2. Generate UUID from String (UUID) : ea33eca1-c704-4062-a111-98f7b323e824
Exit mobile version