Blame view

RandomUtil.java 465 Bytes
涂亚平 committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
package com.subsidy.util;

import java.util.Random;

public class RandomUtil {

    public static int getCode() {
        return (int)((Math.random() * 9 + 1) * 100000);
    }

    public static String getRandomCode(int randomLength) {
        StringBuilder str = new StringBuilder();
        Random random = new Random();
        for (int i = 0; i < randomLength; i++) {
            str.append(random.nextInt(10));
        }
        return str.toString();
    }
}