How to add days to date in Java?
import java.util.Date; import java.util.Calendar; import java.text.DateFormat; import java.text.SimpleDateFormat; public class Test{ public static void main(String[]args){ final Date[]dates=new Date[7]; Calendar cal = Calendar.getInstance(); DateFormat fmt = new SimpleDateFormat("dd-MMM-yyyy"); cal.set(Calendar.MONTH, 2); cal.set(Calendar.YEAR, 2021); for(byte day = 26, i = 0; dates.length > i; day++, i++){ cal.set(Calendar.DAY_OF_MONTH, day); dates[i] = cal.getTime(); } for(Date dt : dates){ System.out.println(fmt.format(dt)); } } } Download