获取两日期之前集合并转为String类型的集合
1 /** 2 * 获取两个日期之间的日期 3 * 4 * @param start 开始日期 5 * @param end 结束日期 6 * @return 日期集合 7 */ 8 private static List<Date> getBetweenDates(Date start, Date end) { 9 List<Date> result = new ArrayList<>(); 10 result.add(start); 11 Calendar tempStart = Calendar.getInstance(); 12 tempStart.setTime(start); 13 tempStart.add(Calendar.DAY_OF_YEAR, 1); 14 15 Calendar tempEnd = Calendar.getInstance(); 16 tempEnd.setTime(end); 17 while (tempStart.before(tempEnd)) { 18 result.add(tempStart.getTime()); 19 tempStart.add(Calendar.DAY_OF_YEAR, 1); 20 } 21 if (start.getTime() != end.getTime()) { 22 result.add(end); 23 } 24 return result; 25 }
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
List<String> strDateList = dateList.stream().map(simpleDateFormat::format).collect(Collectors.toList());
hello world!!!