Java UUID Create getUUID()

Here you can find the source of getUUID()

Description

get UUID

License

Apache License

Declaration

public static String getUUID() 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.util.*;

public class Main {

    public static String getUUID() {
        UUID uuid = UUID.randomUUID();
        return (digits(uuid.getMostSignificantBits() >> 32, 8) + digits(uuid.getMostSignificantBits() >> 16, 4)
                + digits(uuid.getMostSignificantBits(), 4) + digits(uuid.getLeastSignificantBits() >> 48, 4)
                + digits(uuid.getLeastSignificantBits(), 12));
    }/*w  w w  .  ja  va  2 s.  c om*/

    private static String digits(long val, int digits) {
        long hi = 1L << (digits * 4);
        return Long.toHexString(hi | (val & (hi - 1))).substring(1).toLowerCase();
    }

    public static String substring(String str, int start, int count) {
        return str.substring(start, start + count);
    }
}

Related

  1. genMsgId()
  2. genOntologyNS(String base)
  3. genRandom(int length)
  4. genRandomString(int len)
  5. get36UUID()
  6. getUUID()
  7. getUUID(String id)
  8. getUUIDForSql(UUID uuid)
  9. getUUIDValue(String url, String key)