生成19位long型唯一数字id
/** * 生成19位long型唯一数字id * @return */ public static long GetLong19UUID() { // String nanoRandom = System.nanoTime() + "" + random.nextInt(99999); SimpleDateFormat sdf =new SimpleDateFormat("YYMMdd"); String dayTime=sdf.format(new Date()); int hashcode= UUID.randomUUID().toString().hashCode(); if(hashcode<0) { hashcode=-hashcode; } int i = (int)(Math.random()*900 + 100); String value = dayTime+String.format("%010d",hashcode)+ i; long l = Long.parseLong(value); return l; }
吾乃代码搬运工,侵联删