static int countInPeriod ( DayOfWeek dow , DayOfWeek dow0 , int nDays ) { //two cases: // (1a) dow >= dow0: count === (nDays - (dow - dow0)) / 7 // (1b) dow < dow0: count === (nDays - (7 - dow0 - dow)) / 7 if ( dow . getCalendarConstant ( ) >= dow0 . getCalendarConstant ( ) ) { return 1 + ( ( nDays - ( dow . getCalendarConstant ( ) - dow0 . getCalendarConstant ( ) ) - 1 ) / 7 ) ; } else { return 1 + ( ( nDays - ( 7 - ( dow0 . getCalendarConstant ( ) - dow . getCalendarConstant ( ) ) ) - 1 ) / 7 ) ; } }
Counts the number of occurrences of a weekday in a given period .