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); }