public static void main(String[] args){
Date start = DateUtils.parseDate("2018-01-12 00:00:58","yyyy-MM-dd HH:mm:ss");
Date end= DateUtils.parseDate("2018-01-12 00:08:58","yyyy-MM-dd HH:mm:ss");
Date middleTime = getMiddleTime(start,end);
}
public static Date getMiddleTime(Date start,Date end){
Long startL = start.getTime();
Long endL = end.getTime();
Long middleL = (long)startL + (endL-startL)*Math.random();
return new Date(middleL);
}
获取时间段内随机时间点
于 2018-01-23 21:47:23 首次发布