Here is an example that won't work. The condition in the cycle will never be satisfied, because the throw, having reached January 31, 2014, will return to January 1, 2014.
Calendar start=new GregorianCalendar(); start.set(Calendar.YEAR, 2014); start.set(Calendar.MONTH, 0); start.set(Calendar.DAY_OF_MONTH, 1); //January 2, 2014 Calendar end=new GregorianCalendar(); end.set(Calendar.YEAR, 2014); end.set(Calendar.MONTH, 1); end.set(Calendar.DAY_OF_MONTH, 2); //February 2, 2014 while (start.getTime().before(end.getTime())){ start.roll(Calendar.DATE, 1); }
Jadiel de Armas Feb 07 '14 at 6:12 2014-02-07 06:12
source share