public class TimeTest {
public static void main(String[] args) throws ParseException {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Date startTime = sdf.parse("2021-05-01");
Date endTime = sdf.parse("2021-07-01");
Calendar instance = Calendar.getInstance();
instance.setTime(startTime);
ArrayList timeList = new ArrayList<>();
while (!startTime.after(endTime)) {
String time = sdf.format(startTime);
instance.add(Calendar.DAY_OF_MONTH, +1);
startTime=instance.getTime();
timeList.add(time);
System.out.println(time);
}
}
}