public static Date randomDate(Date beginDate,Date endDate ){ if(beginDate.getTime() >= endDate.getTime()){ return new Date(); } long date = random(beginDate.getTime(),endDate.getTime()); return new Date(date); } public static long random(long begin,long end){ long rtn = begin + (long)(Math.random() * (end - begin)); if(rtn == begin || rtn == end){ return random(begin,end); } return rtn; }