//生成16位唯一性的訂單號 public static void getUUID(){ //隨機生成一位整數 int random = (int) (Math.random()*9+1); String valueOf = String.valueOf(random); //生成uuid的hashCode值 int hashCode = UUID.randomUUID().toString().hashCode(); //可能為負數 if(hashCode<0){ hashCode = -hashCode; } String value = valueOf + String.format("%015d", hashCode); System.out.println(value); }
