static Predicate<DateValue> weekIntervalFilter(
            final int interval, final Weekday wkst, final DateValue dtStart) {
        return new Predicate<DateValue>() {
            DateValue wkStart;

            {
                // the latest day with day of week wkst on or before dtStart
                DTBuilder wkStartB = new DTBuilder(dtStart);
                wkStartB.day -=
                        (7 + Weekday.valueOf(dtStart).javaDayNum - wkst.javaDayNum) % 7;
                wkStart = wkStartB.toDate();
            }

            public boolean apply(DateValue date) {
                int daysBetween = TimeUtils.daysBetween(date, wkStart);
                if (daysBetween < 0) {
                    // date must be before dtStart.  Shouldn't occur in practice.
                    daysBetween += (interval * 7 * (1 + daysBetween / (-7 * interval)));
                }
                int off = (daysBetween / 7) % interval;
                return 0 == off;
            }
        };
    }
static Predicate < DateValue > weekIntervalFilter ( final int interval , final Weekday wkst , final DateValue dtStart ) { return new Predicate < DateValue > ( ) { DateValue wkStart ; { DTBuilder wkStartB = new DTBuilder ( dtStart ) ; wkStartB . day -= ( 7 + Weekday . valueOf ( dtStart ) . javaDayNum - wkst . javaDayNum ) % 7 ; wkStart = wkStartB . toDate ( ) ; } public boolean apply ( DateValue date ) { int daysBetween = TimeUtils . daysBetween ( date , wkStart ) ; if ( daysBetween < 0 ) { daysBetween += ( interval * 7 * ( 1 + daysBetween / ( - 7 * interval ) ) ) ; } int off = ( daysBetween / 7 ) % interval ; return 0 == off ; } } ; }
constructs a filter that accepts only every interval-th week from the week
containing dtStart.
@param interval > 0 number of weeks
@param wkst day of the week that the week starts on.
@param dtStart non null