DateUtil { public static List<Date> getRandomDateList(Date startDate, Date endDate, int count) { List<Date> dateList = new ArrayList<>(); if (startDate.getTime() >= endDate.getTime() || count < 1 || count > 10) { logger.warn("getRandomDateList, param illegal, startDate: [{}], endDate: [{}], count: [{}]", startDate.getTime(), endDate.getTime(), count); return dateList; } for (int i = 0; i < count; i++) { dateList.add(new Date(randomTimeStamp(startDate.getTime(), endDate.getTime()))); } if (dateList.size() > 1) { dateList.sort((date1, date2) -> (int) (date1.getTime() - date2.getTime())); } return dateList; } private  DateUtil(); static String getLastDayStr(); static Date getLastDay(); static String getLastWeekStart(String date); static String getWeekStart(String date); static String getOneMonthAgo(); static String getNDay(int n); static Calendar strToCalendar(String dateStr); static Date dateStr2Date(String str); static Date timeStr2Date(String str); static boolean checkNMonthLegal(String dateFrom, String dataTo, int monthNumber); static boolean checkNowBeforeDate(Date date); static boolean checkNowBeforeDate(String dateStr); static boolean checkDateInterval(String startStr, String endStr, String dataStr); static Date getDelayTime(Date date, int second); static List<Date> getRandomDateList(Date startDate, Date endDate, int count);  }
@Test public void getRandomDateList() { Date startDate = new Date(); List<Date> resultList = DateUtil.getRandomDateList(startDate, DateUtil.getDelayTime(startDate, 10), 5); for (Date d : resultList) { System.out.println("getRandomDateList, random date is：" + d.getTime()); } }