java经过UUID生成16位惟一订单号

  public static String getOrderIdByUUId() {
        int first = new Random(10).nextInt(8) + 1;
        int hashCodeV = UUID.randomUUID().toString().hashCode();
        if (hashCodeV < 0) {//有多是负数
            hashCodeV = -hashCodeV;
        }
        // 0 表明前面补充0
        // 4 表明长度为4
        // d 表明参数为正数型
        return first + String.format("%015d", hashCodeV);
    }
相关文章
相关标签/搜索