Date generate from start to end date in java -
I am trying to prepare a list of dates from a given start and end date. I got the solution in stack overflow But, the code provides delivery starting from the month of January. Why am i not able to help please help me
The beginning, ending string is format 'yyyy-mm-dd' . The period is array list , I'm using dates to store dates. Thanks. Your format should be
list & lt; Date & gt; Period = New ArrayList & lt; Date & gt; (); & Lt; Date & gt; Date_req = new arreelist & lt; Date & gt; (); Calendar Start = Calendar.Justation (); Date format format = new simpledate format ("yyyy-mm-dd"); Date date_st = formatter.parse (start); Date date_en = formatter.parse (end); Int init = 0; start.setTime (date_st); Calendar End = Calendar. Just Instance (); end.setTime (date_en); End.add (calendar.DAY_OF_YEAR, 1); // Add 1 day for termination Make sure that the last date is included in the last list, while (start.before (end)) {duration.add (init, start.getTime ()); Start.add (calendar.DAY_OF_YEAR, 1); Init = init + 1; } System.out.println (period);
DateFormat
Comments
Post a Comment