List of utility methods to do Random Number
int | genRandomNumber() gen Random Number if (randomNumber == null) { randomNumber = new Random(); randomNumber.setSeed(System.currentTimeMillis()); int i = randomNumber.nextInt(); if (i < 0) { i *= -1; return i; |
int | genRandomNumber(int begin, int end) gen Random Number int step = Math.abs(end - begin); int random = new Random(System.nanoTime()).nextInt(step); return Math.min(begin, end) + random; |
String | genRandomNumber(int digitNumber) gen Random Number StringBuilder num = new StringBuilder(); Random random = new Random(); for (int i = 0; i < digitNumber; i++) { num.append(random.nextInt(10)); return num.toString(); |
int | genRandomNumber(int minNumber, int maxNumber, int digits) gen Random Number boolean chkExit = true; int isValueOk = randGen.nextInt(digits + 1); while (chkExit) { if (isValueOk < minNumber || isValueOk > maxNumber) { isValueOk = randGen.nextInt(digits + 1); } else { chkExit = false; return isValueOk; |
String | genRandomNumberString(int numberCount) gen Random Number String return genRandomString(1, NONEZERO_NUMBER_CHARS) + genRandomString(numberCount - 1, NUMBER_CHARS);
|
List | genRandomNumList(int num, int count) gen Random Num List if (num < count) { return Collections.EMPTY_LIST; List<Integer> result = new ArrayList<Integer>(); Map<Integer, String> containMap = new HashMap<Integer, String>(); Integer temp = null; Random random = new Random(); for (int i = 0; i < count;) { ... |
boolean | getChance(Number number) get Chance return getChance(number.intValue());
|
String | getDocumentNumber() get Document Number Random random = new Random(); int select = random.nextInt(99) * 1234; int select2 = random.nextInt(alphas.length); return alphas[select2] + "0" + select; |
String | getFlightNumber() get Flight Number Random random = new Random(); Integer select = random.nextInt(999); return select.toString(); |
int | getNextRandomNumber() get Next Random Number return rand.nextInt();
|