Java Random Date getRandomDate()

Here you can find the source of getRandomDate()

Description

get Random Date

License

Open Source License

Declaration

public static String getRandomDate() 

Method Source Code


//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());
    }
}

Related

  1. generateRandomDate()
  2. getDateRand()
  3. getDateRand(Date date)
  4. getDateRandom()
  5. getDateRandomId()
  6. getRandomDate(Random ran, boolean idNewID)