生成若干位数的随机ID的Java工具类

写了如下工具类:

    public class SystemUtil {  
        public static String getRandomNumberByNum(int num) {  
            StringBuffer sb = new StringBuffer();  
            for (int i = 0; i < num; i++) {  
                long randomNum = Math.round(Math.floor(Math.random() * 10.0D));  
                sb.append(randomNum);  
            }  
            return sb.toString();  
        }  
      
          
    }  

以生成10位随机数为例:
    public class Producer {  
        public static String generateIdOfTen() {  
            String randomNumber = SystemUtil.getRandomNumberByNum(10);  
            long time = System.currentTimeMillis();  
            return time + randomNumber;  
        }  
    }  

编程技巧