Here you can find the source of getIdByTime(String name)
public static synchronized String getIdByTime(String name)
//package com.java2s; import java.text.Format; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Random; public class Main { public static synchronized String getIdByTime(String name) { return name + "-" + getCurrDate() + "-" + getCurrTime() + "-" + getRandomNumber(); }// ww w . j a v a 2s . c om public static String getCurrDate() { Date date = new Date(); Format formatter = new SimpleDateFormat("yyyy.MM.dd"); return formatter.format(date); } public static String getCurrTime() { Date date = new Date(); Format formatter = new SimpleDateFormat("HH.mm.ss"); return formatter.format(date); } public static String getRandomNumber() { Random random = new Random(); String retval = String.valueOf(random.nextInt(100)); return retval; } }