private static final String ALLOWED_CHARS = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; private static final int UUID_LENGTH = 36; public static String generateUUID() { StringBuilder uuidBuilder = new StringBuilder(UUID_LENGTH); Random random = new Random(); for (int i = 0; i < UUID_LENGTH; i++) { if (i == 8 || i == 13 || i == 18 || i == 23) { uuidBuilder.append('-'); } else { uuidBuilder.append(ALLOWED_CHARS.charAt(random.nextInt(ALLOWED_CHARS.length()))); System.out.println(uuidBuilder+"[][][][][][][][][][][][][][]"); } } return uuidBuilder.toString(); } public static void main(String[] args) { String customUUID = generateUUID(); System.out.println(customUUID); }