Java Random Number getRandomNum()

Here you can find the source of getRandomNum()

Description

get Random Num

License

Open Source License

Declaration

public static String getRandomNum() 

Method Source Code


//package com.java2s;

import java.text.SimpleDateFormat;

public class Main {
    public static final String DATE_FORMAT_YYYYMMDDHHMM = "yyyyMMddHHmm";

    public static String getRandomNum() {
        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();
    }//  www . ja v  a 2  s.c  o m

    public static String dataToString(Object date, String format) {
        SimpleDateFormat df = new SimpleDateFormat(format);
        return df.format(date);
    }
}

Related

  1. getRandNum(int num)
  2. getRandNumber(int maxNumber)
  3. getRandomDouble(double max, String decimalFormat)
  4. getRandomNum()
  5. getRandomNum()
  6. getRandomNum()
  7. getRandomNum(double pSngBegin, double pSngEnd)
  8. getRandomNum(int len)
  9. getRandomNum(int pwd_len)