Is there an easy way to do something like getting the 2nd Thursday of a given month? As an example, here is code I wrote that gets the next Thanksgiving. I think it works correctly, but is there an easier way to do this?
private static LocalDate getThanksgiving(int year) { LocalDate ld = new LocalDate(year, 11, 1); if (ld.getDayOfWeek() != DateTimeConstants.THURSDAY) { // Move back to the previous Thursday. ld = ld.withDayOfWeek(DateTimeConstants.THURSDAY); if (ld.monthOfYear().get() != DateTimeConstants.NOVEMBER) { ld = ld.plusWeeks(1); // move forward into November } } return ld.plusWeeks(3); // to get to 4th Thursday } } // Now call that method like this. LocalDate thanksgiving = getThanksgiving(year); if (thanksgiving.isBefore(today)) { thanksgiving = getThanksgiving(year + 1); } --- Mark Volkmann ------------------------------------------------------------------------------ _______________________________________________ Joda-interest mailing list Joda-interest@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/joda-interest