遍历日期20171102到20201130的
public void printdate() throws Exception{
SimpleDateFormat sf=new SimpleDateFormat("yyyyMMdd");
//开始日期
Date startDate=sf.parse("20171102");
//结束日期
Date endDate=sf.parse("20201130");
//定义日期累加打印时间
Date ls=startDate;
//获得通用对象,能计算时间
Calendar date=Calendar.getInstance();
date.setTime(startDate);
//循环遍历
while(ls.getTime()<endDate.getTime()){
//将时间赋值
ls=date.getTime();
//打印
System.out.println(sf.format(ls));
date.add(Calendar.DAY_OF_MONTH, 1);//日期加1
}
}

浙公网安备 33010602011771号