Q:

Java - How to get the last day of the week of the month

Is it possible to get the last day of the last week for the current month.
For instance, I want to get 31st as the last day of Week 5 for the month of August and 3rd as the the last day of Week 1 for the month of September.
Edit:
I am using this week as an example.There are 2 months in this week so I need to generated 2 different weekly reports to represent each month. so first report will be 28th to 31st of August and the second report will be 1st to 3rd of September. Week starts on Sunday

A:

Edit: after your clarification in the comments here’s a solution. Given a month it returns a list containing one or two dates: one date if the month ends on a Saturday and thus with a whole week; if not, both the last day of the month and the following Saturday, where the week ends.
public static final int lastDayOfWeek = Calendar.SATURDAY;

/** month is 1 through 12 for Jan through Dec */
public static List<Date> lastDayOfLastWeek(int year, int month) {
    Calendar cal = Calendar.getInstance();
    // set to a day in the month in question; Calendar’s month is 0-based, so subtract 1
    cal.set(year, month - 1, 1);
    // set to last day of month
    cal.set(Calendar.DAY_OF_MONTH, cal.getActualMaximum(Calendar.DAY_OF_MONTH));
    List<Date> result = new ArrayList<Date>(2);
    result.add(cal.getTime());
    // is this also the last day of the week?
    int dayOfWeek = cal.get(Calendar.DAY_OF_WEEK);
    if (dayOfWeek != lastDayOfWeek) { // no
        // set to last day of week and add one more date to result
        cal.add(Calendar.DAY_OF_WEEK, lastDayOfWeek - dayOfWeek);
        result.add(cal.getTime());
    }
    return result;
}

For example, for April 2016 it returns just Saturday 30 April. For August it returns Wed 31 Aug and Sat 3 Sep since these are the dates where the two periods end that you need to build reports for. 

