How to Convert a String to a UUID in Java? Last Updated : 21 Mar, 2024 Comments Improve Suggest changes Like Article Like Report A Universally Unique Identifier (UUID) is a 128-bit label utilised for information in computer systems. The term Globally Unique Identifier (GUID) is also used especially in Microsoft systems. UUIDs are regularised by the Open Software Foundation (OSF) as part of the Distributed Computing Environment (DCE). When generated according to the standard methods, UUIDs are usually unique(mostly). In this article, we will see how to Convert a String to a UUID in Java. Generating UUIDThe Code below shows how to generate a UUID: Java import java.util.UUID; class GenerateUuid { public static void main (String[] args) { UUID uuid = UUID.randomUUID(); String uuidAsString = uuid.toString(); System.out.println("Your UUID as String is:- "+ uuidAsString); } } OutputYour UUID as String is:- 80412d77-5abb-4893-ac56-a2de12e7931c Converting String to UUIDAlthough it is very much less likely to be used but in some circumstances UUID are required to be converted in Strings. Java allows this convertion using the static fromString(String) method. Syntax: public static UUID fromString(String UUID_name)The below code shows the conversion: Java import java.util.UUID; class MyUuidApp { public static void main(String[] args) { UUID uuid = UUID.randomUUID(); String uuidAsString = uuid.toString(); UUID Uuid = UUID.fromString(uuidAsString); System.out.println("The UUID for the given string is : "+ Uuid); } } OutputThe UUID for the given string is : 4731e9e0-c627-43f9-808a-7e8637abb912 Comment More infoAdvertise with us Next Article How to Convert a String to a UUID in Java? A ankur101245 Follow Improve Article Tags : Java Java Programs Java Examples Practice Tags : Java Similar Reads How to Convert a String to URL in Java? In Java, a string is a sequence of characters. A URL, which is short for Uniform Resource Locator, refers to a web resource that specifies its location on a computer network and provides the mechanism for retrieving it. To represent a URL in Java, we use the java.net.URL class. In this article, we w 2 min read How to Convert a String to a Path in Java? In Java, we can convert a String representation of a file or directory path into a path object using the Paths utility class. It is a part of the java.nio.file package. The Paths class provides a method called get(String file path location) that converts a sequence of strings representing a path int 2 min read How to Convert Char to String in Java? In this article, we will learn how to Convert Char to String in Java. If we have a char value like 'G' and we want to convert it into an equivalent String like "G" then we can do this by using any of the following three listed methods in Java. Using toString() method of Character classUsing valueOf( 5 min read How to Convert a String to an Long in Java ? In Java, String to Integer Conversion is not always effective as the size of the String can overpass Integer. In this article, we will learn the method provided by the Long class or by using the constructor of the Long class. Example of String to Long ConversionInput: " 9876543210"Output: 9876543210 2 min read How to Convert a String to a Character in Java? String and char are fundamental and most commonly used datatypes in Java. A String is not a primitive data type like char. To convert a String to char in Java, we have to perform character-based operations or have to process individual characters.In this article, we will learn how to convert a Strin 3 min read Like