1.工具类:
package UUIdtest; import java.util.UUID; public class UUIDUtil { public static String getUUID() { return UUID.randomUUID().toString(); } }
2.使用
package UUIdtest; import org.junit.Test; public class TestUUID { @Test public void test3(){ System.out.println(UUIDUtil.getUUID().replace("-", "")); System.out.println(UUIDUtil.getUUID()); System.out.println(UUIDUtil.getUUID()); } }
时间: 2024-10-14 04:33:55