Here you can find the source of getRandomDate()
public static String getRandomDate()
//package com.java2s; import java.util.Date; import java.util.GregorianCalendar; public class Main { public static String getRandomDate() { long time = System.currentTimeMillis(); Date dat = new Date(time); GregorianCalendar gc = new GregorianCalendar(); gc.setTime(dat);//from w w w . j ava 2 s.co m java.text.SimpleDateFormat format = new java.text.SimpleDateFormat("yyyy-MM-dd hh:mm:ss"); return format.format(gc.getTime()); } }