List of utility methods to do Random Number
String | getRandNum(int num) get Rand Num String randnum = ""; for (int i = 0; i < num; i++) { Random rand = new Random(); randnum += rand.nextInt(10); return randnum; |
int | getRandNumber(int maxNumber) get Rand Number return rand.nextInt(maxNumber);
|
double | getRandomDouble(double max, String decimalFormat) get Random Double DecimalFormat formatter = new DecimalFormat(decimalFormat); return Double.parseDouble(formatter.format(Math.random() * max)); |
long | getRandomNum() Return a random long number. final Random generator = new Random(); return generator.nextLong(); |
int | getRandomNum() get integer random number return rnd.nextInt();
|
String | getRandomNum() get Random Num SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssS"); Date now = new Date(); String s = sdf.format(now); Random rd = new Random(); int rdNum = rd.nextInt(1000); String subDir = s + String.valueOf(rdNum); return subDir; |
String | getRandomNum() get Random Num StringBuffer sb = new StringBuffer(); sb.append(dataToString(new java.util.Date(), DATE_FORMAT_YYYYMMDDHHMM)); sb.append(String.valueOf(Math.round(Math.random() * 8999 + 1000))); return sb.toString(); |
double | getRandomNum(double pSngBegin, double pSngEnd) get Random Num if (pSngEnd < pSngBegin) { throw new IllegalArgumentException("pSngEnd must not smaller than pSngBegin"); return (pSngEnd - pSngBegin) * Math.random() + pSngBegin; |
String | getRandomNum(int len) get Random Num Random random = new Random(); StringBuffer strNum = new StringBuffer(); for (int i = 0; i < len; i++) { int num = random.nextInt(10); strNum.append(num); return strNum.toString(); |
String | getRandomNum(int pwd_len) get Random Num String randomStr = "abcdefghijklmnopqrstuvwxyz0123456789"; final int maxNum = 36; int i; int count = 0; char[] str = randomStr.toCharArray(); StringBuffer pwd = new StringBuffer(""); Random r = new Random(); while (count < pwd_len) { ... |