Here you can find the source of generateId()
public static String generateId()
//package com.java2s; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Random; public class Main { public static String generateId() { Date date = new Date(); // SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy h:mm:ss a"); SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd-hhmmss"); String formattedDate = sdf.format(date); Random r = new Random(); return formattedDate + "-" + r.nextInt(10000); }//from ww w . j av a2s . c o m }