public void addAppointments ( Anniversary recAnniversary , Calendar calStart , Calendar calEnd ) { try { Converter . initGlobals ( ) ; Calendar calendar = Converter . gCalendar ; Record recRepeat = ( ( ReferenceField ) this . getField ( AnnivMaster . REPEAT_INTERVAL_ID ) ) . getReference ( ) ; String strRepeat = null ; if ( recRepeat != null ) strRepeat = recRepeat . getField ( RepeatInterval . DESCRIPTION ) . toString ( ) ; char chRepeat ; if ( ( strRepeat == null ) || ( strRepeat . length ( ) == 0 ) ) chRepeat = ' ' ; else chRepeat = strRepeat . toUpperCase ( ) . charAt ( 0 ) ; int iRepeatCode ; if ( chRepeat == ' ' ) iRepeatCode = Calendar . DATE ; else if ( chRepeat == ' ' ) iRepeatCode = Calendar . WEEK_OF_YEAR ; else if ( chRepeat == ' ' ) iRepeatCode = Calendar . MONTH ; else iRepeatCode = Calendar . YEAR ; short sRepeatCount = ( short ) this . getField ( AnnivMaster . REPEAT_COUNT ) . getValue ( ) ; if ( sRepeatCount == 0 ) sRepeatCount = 1 ; Date timeStart = ( ( DateTimeField ) this . getField ( AnnivMaster . START_DATE_TIME ) ) . getDateTime ( ) ; Date timeEnd = ( ( DateTimeField ) this . getField ( AnnivMaster . END_DATE_TIME ) ) . getDateTime ( ) ; long lTimeLength = - 1 ; if ( timeEnd != null ) lTimeLength = timeEnd . getTime ( ) - timeStart . getTime ( ) ; calendar . setTime ( timeStart ) ; for ( int i = 0 ; i < 100 ; i ++ ) { if ( ( calendar . after ( calStart ) ) && ( calendar . before ( calEnd ) ) ) { timeStart = calendar . getTime ( ) ; timeEnd = null ; if ( lTimeLength != - 1 ) timeEnd = new Date ( timeStart . getTime ( ) + lTimeLength ) ; recAnniversary . addNew ( ) ; ( ( DateTimeField ) recAnniversary . getField ( Anniversary . START_DATE_TIME ) ) . setDateTime ( timeStart , false , DBConstants . SCREEN_MOVE ) ; if ( timeEnd != null ) ( ( DateTimeField ) recAnniversary . getField ( Anniversary . END_DATE_TIME ) ) . setDateTime ( timeEnd , false , DBConstants . SCREEN_MOVE ) ; recAnniversary . getField ( Anniversary . DESCRIPTION ) . moveFieldToThis ( this . getField ( AnnivMaster . DESCRIPTION ) ) ; ( ( ReferenceField ) recAnniversary . getField ( Anniversary . ANNIV_MASTER_ID ) ) . setReference ( this ) ; recAnniversary . getField ( Anniversary . CALENDAR_CATEGORY_ID ) . moveFieldToThis ( this . getField ( AnnivMaster . CALENDAR_CATEGORY_ID ) ) ; recAnniversary . getField ( Anniversary . HIDDEN ) . moveFieldToThis ( this . getField ( AnnivMaster . HIDDEN ) ) ; // Don't move properties (you will have to read the AnnivMaster to get the properties) recAnniversary . add ( ) ; } calendar . add ( iRepeatCode , sRepeatCount ) ; } } catch ( DBException ex ) { ex . printStackTrace ( ) ; } }
AddAppointments Method .