public List <String> getDate (a Date dBegin, a Date DEND) { List <String> = dateList new new the ArrayList (); dateList.add (DateUtil.formatDate (dBegin)); Calendar calBegin = Calendar.getInstance (); // used to predetermined time set this Calendar date calBegin.setTime (dBegin); Calendar calend = Calendar.getInstance (); // the given time set this Calendar date calEnd.setTime (DEND); // test whether this date after the specified date the while (dEnd.after (calBegin.getTime ())) { // the amount of time in accordance with the rules of the calendar, add or subtract specified for a given calendar field calBegin.add(Calendar.DAY_OF_MONTH, 1); dateList.add(DateUtil.formatDate(calBegin.getTime())); } return dateList; }
DateUtil a kit is introduced
<!--工具包 --> <dependency> <groupId>cn.hutool</groupId> <artifactId>hutool-all</artifactId> <version>4.5.11</version> </dependency> <!--工具包 end-->
public List <String> getDate (a Date dBegin , a Date DEND) {
List <String> = dateList new new the ArrayList () ;
dateList.add (the DateUtil. the formatDate (dBegin)) ;
. = Calendar Calendar calBegin the getInstance () ;
// used to predetermined time set this Calendar date
calBegin.setTime (dBegin) ;
. = Calendar Calendar calend the getInstance () ;
// set the given time this Calendar date
calEnd.setTime (DEND) ;
// test whether this date after the specified date
the while (dEnd.after (calBegin.getTime ())) {
the amount of time a calendar // rules, designated to add or subtract a given calendar field
calBegin.add(Calendar.DAY_OF_MONTH, 1);
dateList.add(DateUtil.formatDate(calBegin.getTime()));
}
return dateList;
}