import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
String startDateStr = "2023-09-10";
String endDateStr = "2023-10-01";
LocalDate localStartDate = LocalDate.parse(startDateStr);
LocalDate localEndDate = LocalDate.parse(endDateStr);
DateTimeFormatter deteFormat = DateTimeFormatter.ofPattern("yyyy-MM-dd");
while(!localStartDate.isAfter(localEndDate)) {
String dateStr = localStartDate.format(deteFormat);
System.out.println(dateStr);
//业务逻辑处理......
localStartDate = localStartDate.plusDays(1);
}
String类型起止日期遍历
于 2023-09-12 09:57:28 首次发布