代码如下:
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
public class DateUtil {
public static List<String> getDates(String dBegin, String dEnd) throws ParseException, java.text.ParseException {
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
Calendar calBegin = Calendar.getInstance();
calBegin.setTime(format.parse(dBegin));
Calendar calEnd = Calendar.getInstance();
calEnd.setTime(format.parse(dEnd));
List<String> Datelist = new ArrayList<String>();
Datelist.add(format.format(calBegin.getTime()));
while (format.parse(dEnd).after(calBegin.getTime())) {
calBegin.add(Calendar.DAY_OF_MONTH, 1);
Datelist.add(format.format(calBegin.getTime()));
}
return Datelist;
}
}