There are two simple ways to generate a value:

1. Get the system date time:

// Get the current date and time from system.
DateFormat dateFormat = new SimpleDateFormat(“yyyyMMddHHmmss”);
Calendar cal = Calendar.getInstance();
String GetDateTime = dateFormat.format(cal.getTime());

The Result: 20160528010203

2. Get a random number:

Random rd = new Random();
for (int idx = 1000; idx <= 100000; ++idx) {
randomInt = rd.nextInt(100000);

The Result: 95018

Example code in real:

Leave a Comment

Your email address will not be published. Required fields are marked *