demo:
package com.test; import java.util.UUID; /** * JDK1.5以上 * */ public class UUIDTest { public static void main(String[] args) { UUID uuid = UUID.randomUUID(); System.out.println(uuid); } }
输出结果:
1 fd61384b-05a5-4030-885e-a6bd3b60ef1a
下面是去除UUID中的"-"
1 /** 2 * 3 */ 4 package com.testUuid; 5 6 import java.util.UUID; 7 8 /** 9 * @date 2012-11-7 10 * @author xhw 11 *