public void 两个日期之间的所有天数(String startDate, String endDate) {
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
SimpleDateFormat dayFormat = new SimpleDateFormat("yyyy-MM-dd");
try {
Calendar editStartPeriod = Calendar.getInstance();
editStartPeriod.setTime(format.parse(startDate));
Calendar editEndPeriod = Calendar.getInstance();
editEndPeriod.setTime(format.parse(endDate));
Calendar curr = editStartPeriod;
while (curr.before(editEndPeriod)) {
System.out.println(dayFormat.format(curr.getTime()));
curr.add(Calendar.DATE, 1);
}
} catch (ParseException e) {
e.printStackTrace();
}
}
java 两个日期之间的所有天数
最新推荐文章于 2023-02-13 22:28:51 发布