欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  Java

Java唯一码生成

程序员文章站 2022-04-22 16:58:12
...
private static String beforeBh;
 private static String beforeNum;
public static String codeGenerate() {
   Date now = new Date();
   String behind = now.getTime()+"";
   if(beforeBh==null) {
    beforeBh = behind;
   } else if(beforeBh.equals(behind)) {
    behind = behind +beforeNum;
    beforeNum++;
   } else {
    beforeBh = behind;
    beforeNum = 0;
   }
   return behind;