Java tutorial
//package com.java2s; //License from project: Apache License import java.util.UUID; public class Main { private static final String BASE_UUID_FORMAT = "0000%s-0000-1000-8000-00805F9B34FB"; public static UUID getUUID(String uuid) { try { return UUID.fromString(uuid); } catch (IllegalArgumentException iae) { if (uuid.matches("[0-9a-fA-F]{4}")) { return UUID.fromString(String.format(BASE_UUID_FORMAT, uuid.toUpperCase())); } } return null; } }