In plain Java, I have this code to get the last Sunday of the month.
Calendar getNthOfMonth(int n, int day_of_week, int month, int year) {
Calendar compareDate = Date(1, month, year);
compareDate.set(DAY_OF_WEEK, day_of_week);
compareDate.set(DAY_OF_WEEK_IN_MONTH, n);
return compareDate;
}
// Usage
Calendar lastSundayOfNovember = getNthOfMonth(-1, SUNDAY, NOVEMBER, 2012)
What is a clean and elegant way to achieve the same result using Joda-Time
?