I just wasted like 30 minutes trying to figure it out myself, but I generally had to jump forward.
Anyway, here is my solution:
public static DateTime rollForwardWith(ReadableInstant now, AbstractPartial lp) { DateTime dt = lp.toDateTime(now); while (dt.isBefore(now)) { dt = dt.withFieldAdded(lp.getFieldTypes()[0].getRangeDurationType(), 1); } return dt; }
Now you just need to do Partial (which is LocalDate) for the day of the week.
Partial().with(DateTimeFieldType.dayOfWeek(), DateTimeConstants.FRIDAY);
Now, whatever the most significant field for the partial, there will be +1 if the current date is after it (now).
That is, if you partial from March 2012, it will create a new date-time in March 2013 or <.
Adam Gent Jul 18 '12 at 3:01 2012-07-18 03:01
source share