private List<Date> getDates(Date startDate, Date endDate) throws ParseException{
List<Date> result = new ArrayList<Date>();
if (startDate.getTime() == endDate.getTime()) {
result.add(endDate);
return result;
}
Calendar tempStart = Calendar.getInstance();
tempStart.setTime(startDate);
//tempStart.add(Calendar.DAY_OF_YEAR, 1); 不含起始日期
Calendar tempEnd = Calendar.getInstance();
tempEnd.setTime(endDate);
while (tempStart.before(tempEnd)) {
result.add(tempStart.getTime());
tempStart.add(Calendar.DAY_OF_YEAR, 1);
}
private List<String> getStringDates(List<Date> dates){
List<String> result = new ArrayList<String>();
if (dates != null && dates.size() > 0) {
SimpleDateFormat sft = new SimpleDateFormat("yyyy-MM-dd");
}
return result;
}
List<Date> result = new ArrayList<Date>();
if (startDate.getTime() == endDate.getTime()) {
result.add(endDate);
return result;
}
Calendar tempStart = Calendar.getInstance();
tempStart.setTime(startDate);
//tempStart.add(Calendar.DAY_OF_YEAR, 1); 不含起始日期
Calendar tempEnd = Calendar.getInstance();
tempEnd.setTime(endDate);
while (tempStart.before(tempEnd)) {
result.add(tempStart.getTime());
tempStart.add(Calendar.DAY_OF_YEAR, 1);
}
result.add(tempEnd .getTime()); //加入当天日期
}
private List<String> getStringDates(List<Date> dates){
List<String> result = new ArrayList<String>();
if (dates != null && dates.size() > 0) {
SimpleDateFormat sft = new SimpleDateFormat("yyyy-MM-dd");
for (Date d:dates) {
if (!result.contains(sft.format(d))) { //去重
result.add(sft.format(d));
}
}}
return result;
}