Joda-Time doesn't have anything to help with this particular calculation (JSR-310 does).
The withDayfWeek() method adjusts the day within the current Monday to Sunday week. Stephen Kevin Bourrillion wrote: > I was wondering the same thing just yesterday. > > > On Fri, Dec 19, 2008 at 7:02 AM, Mark Volkmann <m...@ociweb.com > <mailto:m...@ociweb.com>> wrote: > > LocalDate ld = new LocalDate(year, 11, 1); > if (ld.getDayOfWeek() != DateTimeConstants.THURSDAY) { > > > At this point, 'd.plusDays(THURSDAY - d.getDayOfWeek() + 7) % 7)' should > get you straight to the first Thursday, right? I don't know what's the > best way, though. I also couldn't find an explanation of what > .withDayOfWeek() does -- does it always move backward? > > K > > > > > // 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 > <mailto:Joda-interest@lists.sourceforge.net> > https://lists.sourceforge.net/lists/listinfo/joda-interest > > > > > -- > Kevin Bourrillion @ Google > internal: http://go/javalibraries > google-collections.googlecode.com <http://google-collections.googlecode.com> > google-guice.googlecode.com <http://google-guice.googlecode.com> > > > ------------------------------------------------------------------------ > > ------------------------------------------------------------------------------ > > > ------------------------------------------------------------------------ > > _______________________________________________ > Joda-interest mailing list > Joda-interest@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/joda-interest ------------------------------------------------------------------------------ _______________________________________________ Joda-interest mailing list Joda-interest@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/joda-interest