import java.text.SimpleDateFormat;
import java.util.Calendar;public class TimerTest {public static void main(String[] args) throws Exception {String beginDate = "2016-07-16";//开始时间String endDate = "2016-07-25";//结束时间SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");Calendar cal = Calendar.getInstance();cal.setTime(sdf.parse(beginDate));for (long d = cal.getTimeInMillis(); d <= sdf.parse(endDate).getTime(); d = get_D_Plaus_1(cal)) {System.out.println(sdf.format(d));}}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();}
}
运行结果: