UUID生成纯数字ID

UUID

public class UUIDUtils {
    public static String getUUID(){
        return UUID.randomUUID().toString().replace("-","");
    }

    public static Integer getUUIDInOrderId(){
        Integer orderId=UUID.randomUUID().toString().hashCode();
        orderId = orderId < 0 ? -orderId : orderId; //String.hashCode() 值会为空
        return orderId;
    }

    public static void main(String[] args){
        for (int i = 0; i<100; i++)
        System.out.println(UUIDUtils.getUUIDInOrderId());
    }
}

 

posted @ 2019-06-18 22:21  白夜梦鱼  阅读(20305)  评论(1编辑  收藏  举报