Home >Java >javaTutorial >Java unique code generation

Java unique code generation

大家讲道理
大家讲道理Original
2016-11-10 10:25:371431browse

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;


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn