public int approximateIntervalInDays ( ) { int freqLengthDays ; int nPerPeriod = 0 ; switch ( this . freq ) { case DAILY : freqLengthDays = 1 ; break ; case WEEKLY : freqLengthDays = 7 ; if ( ! this . byDay . isEmpty ( ) ) { nPerPeriod = this . byDay . size ( ) ; } break ; case MONTHLY : freqLengthDays = 30 ; if ( ! this . byDay . isEmpty ( ) ) { for ( WeekdayNum day : byDay ) { // if it's every weekday in the month, assume four of that weekday, // otherwise there is one of that week-in-month,weekday pair nPerPeriod += 0 != day . num ? 1 : 4 ; } } else { nPerPeriod = this . byMonthDay . length ; } break ; case YEARLY : freqLengthDays = 365 ; int monthCount = 12 ; if ( 0 != this . byMonth . length ) { monthCount = this . byMonth . length ; } if ( ! this . byDay . isEmpty ( ) ) { for ( WeekdayNum day : byDay ) { // if it's every weekend in the months in the year, // assume 4 of that weekday per month, // otherwise there is one of that week-in-month,weekday pair per // month nPerPeriod += ( 0 != day . num ? 1 : 4 ) * monthCount ; } } else if ( 0 != this . byMonthDay . length ) { nPerPeriod += monthCount * this . byMonthDay . length ; } else { nPerPeriod += this . byYearDay . length ; } break ; default : freqLengthDays = 0 ; } if ( 0 == nPerPeriod ) { nPerPeriod = 1 ; } return ( ( freqLengthDays / nPerPeriod ) * this . interval ) ; }
an approximate number of days between occurences .