I want to get the last day of the next three weeks.
For example, if today is Wednesday, April 16th, I will get the result Sunday, May 4th.
I wrote a function like
public static Date nexThreeWeekEnd() {
Date now = new Date();
Date nextWeeks = DateUtils.truncate(DateUtils.addWeeks(now, 3), Calendar.DATE);
Calendar calendar = Calendar.getInstance();
calendar.setTime(nextWeeks);
calendar.set(Calendar.DATE, calendar.getActualMaximum(Calendar.DAY_OF_WEEK));
return calendar.getTime();
}
DateUtils is used from this library:
org.apache.commons.lang.time.DateUtils;
But this function will return on Wednesday, May 7, which means that it will return exactly on the day of the current date.
No need to rewrite my function. Any other ways to solve my problem would be very helpful. Thank you
source
share