Its not pretty but I'm trying to run an API call for a select date range. For some reason I'm not breaking out of my while loop. Hopefully someone can tell me what I'm doing wrong. Its pretty simple code I think.
String modifiedStartDate;
String modifiedEndDate;
// Setup Initial Dates
Calendar c = Calendar.getInstance();
c.set(2022, 0, 1);
date = c.getTime();
modifiedStartDate = new SimpleDateFormat("yyyy-MM-dd").format(date);
c.add(Calendar.DATE, 1);
date = c.getTime();
modifiedEndDate = new SimpleDateFormat("yyyy-MM-dd").format(date);
while (modifiedEndDate != "2022-01-04"){
System.out.println("Start: " + modifiedStartDate);
System.out.println("Start: " + modifiedEndDate);
c.add(Calendar.DATE, 1);
date = c.getTime();
modifiedStartDate = new SimpleDateFormat("yyyy-MM-dd").format(date);
c.add(Calendar.DATE, 1);
date = c.getTime();
modifiedEndDate = new SimpleDateFormat("yyyy-MM-dd").format(date);
}
The output keeps going indefinitely; see below Start: 2022-01-01 Start: 2022-01-02 Start: 2022-01-03 Start: 2022-01-04 Start: 2022-01-05 Start: 2022-01-06 Start: 2022-01-07 Start: 2022-01-08 and on and on and on :)