生成唯一订单号

   protected final static SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");   
   /**
* 产生唯一 的序列号。 * @return */ public String getSerialNumber() { int hashCode = UUID.randomUUID().toString().hashCode(); if(hashCode < 0) { hashCode = - hashCode; }
return sdf.format(new Date()).substring(2,8) + String.format("%010d", hashCode); }

十进制整数输出,宽度10位,不足前面补0;
比如:
printf("%010d", 234);
输出:0000000234

原文地址:https://www.cnblogs.com/BINGJJFLY/p/7477124.html