12345678910111213141516171819202122232425262728293031 |
- package com.kmall.common.utils;
- import java.util.Random;
- /**
- * /**
- * 随机数工具类
- *
- * @author zhangjun
- * @version 1.0.0
- * 2018-12-07 16:00
- */
- public class RandomUtils {
- /**
- * 获取一个指定位数的随机数
- *
- * @param bit 指定位数
- * @return 随机数
- */
- public static String getNum(int bit) {
- if (bit > 0) {
- StringBuffer sb = new StringBuffer();
- for (int i = 0; i < bit; i++) {
- sb.append(new Random().nextInt(10));
- }
- return sb.toString();
- }
- return null;
- }
- }
|