public class TestDate {
public static void main(String[] args) throws Exception {
String beginDate = "2018-01-01";//开始时间
String endDate = "2018-02-11";//结束时间
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Calendar cal = Calendar.getInstance();
cal.setTime(sdf.parse(beginDate));
Map<String,Object> map = new FastTreeMap();
for (long d = cal.getTimeInMillis(); d <= sdf.parse(endDate).getTime(); d = get_D_Plaus_1(cal)) {
map.put(sdf.format(d),"");
//list.add(sdf.format(d));
System.out.println(sdf.format(d));
}
System.out.println(map);
}
public static long get_D_Plaus_1(Calendar c) {
c.set(Calendar.DAY_OF_MONTH,c.get(Calendar.DAY_OF_MONTH) + 1);
return c.getTimeInMillis();
}
}