I have a given task but don't really understand what to perform in this function. Here is the given code:
// Returns a Date value that is num days after current Date
public Date daysAfter(int num) {
return null;
}
I have a given task but don't really understand what to perform in this function. Here is the given code:
// Returns a Date value that is num days after current Date
public Date daysAfter(int num) {
return null;
}
The easiest approach, IMHO, would be to use a Calendar object:
public static Date daysAfter(int num) {
Calendar cal = Calendar.getInstance();
cal.add(Calendar.DATE, num);
return cal.getTime();
}
You can get date plus your provided day as below:
public static LocalDate getDateAfter(Integer days) {
return LocalDate.now().plusDays(days);
}