Java - java.util.UUID

 UUID,Universally Unique Identifier,通用唯一识别码

public class TestUUID {

	public static void main(String[] args) {
		
		String mUUID = java.util.UUID.randomUUID().toString();
		System.out.println(mUUID);  
		// 9528f93c-c85f-41d7-90d0-6003f2664086
		
		System.out.println(mUUID.replace("-", ""));
		// 9528f93cc85f41d790d06003f2664086
	
	}
	
}


UUID 的字符串表示形式由此 BNF 描述:

 UUID                   =  "-"  "-"
                            "-"
                            "-"
                           
  time_low               = 4*
  time_mid               = 2*
  time_high_and_version  = 2*
  variant_and_sequence   = 2*
  node                   = 6*
  hexOctet               = 
  hexDigit               =
        "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9"
        | "a" | "b" | "c" | "d" | "e" | "f"
        | "A" | "B" | "C" | "D" | "E" | "F"




你可能感兴趣的:(Java,基础,java,UUID)