public static GregorianCalendar getRandomDate ( long seed ) { GregorianCalendar gc = new GregorianCalendar ( ) ; Random rand = new Random ( seed ) ; gc . set ( GregorianCalendar . YEAR , 1900 + rand . nextInt ( 120 ) ) ; //Between 1900 & 2020 gc . set ( GregorianCalendar . DAY_OF_YEAR , rand . nextInt ( 364 ) + 1 ) ; //Day of year return gc ; }
Gets a random date in the last 100 years