0

Could you please explain why the below code failed at

c1.add(Calendar.MONTH, 1);

The input is getListOfDatesBwTwoDates("01/01/2020", "06/15/2020","mm/dd/yyyy"); No error returned but the list returned is only [01/01/2020]; I tried but couldn't figure it out.

Ivy
  • 41
  • 5
  • Do you not get an error message that is supposed to be posted here? – akuzminykh May 08 '20 at 03:46
  • Hi, I just edit the question.The input is getListOfDatesBwTwoDates("01/01/2020", "06/15/2020","mm/dd/yyyy"); but the list returned is only [01/01/2020]; – Ivy May 08 '20 at 03:48
  • No error is returned but it seems the c1.add(Calendar.MONTH, 1) does not work so the while loop stop after 1st of execution. – Ivy May 08 '20 at 03:49
  • I recommend you don’t use `Calendar`. That class is poorly designed and long outdated. Instead use `LocalDate` from [java.time, the modern Java date and time API](https://docs.oracle.com/javase/tutorial/datetime/). – Ole V.V. May 10 '20 at 18:52

1 Answers1

0

the error is here :

getListOfDatesBwTwoDates("01/01/2020", "06/15/2020","mm/dd/yyyy");

You should used

getListOfDatesBwTwoDates("01/01/2020", "06/15/2020","**MM**/dd/yyyy");
DaviLevi
  • 58
  • 1
  • 6