private void readHours ( ProjectCalendar calendar , Day day , Integer hours ) { int value = hours . intValue ( ) ; int startHour = 0 ; ProjectCalendarHours calendarHours = null ; Calendar cal = DateHelper . popCalendar ( ) ; cal . set ( Calendar . HOUR_OF_DAY , 0 ) ; cal . set ( Calendar . MINUTE , 0 ) ; cal . set ( Calendar . SECOND , 0 ) ; cal . set ( Calendar . MILLISECOND , 0 ) ; calendar . setWorkingDay ( day , false ) ; while ( value != 0 ) { // Move forward until we find a working hour while ( startHour < 24 && ( value & 0x1 ) == 0 ) { value = value >> 1 ; ++ startHour ; } // No more working hours, bail out if ( startHour >= 24 ) { break ; } // Move forward until we find the end of the working hours int endHour = startHour ; while ( endHour < 24 && ( value & 0x1 ) != 0 ) { value = value >> 1 ; ++ endHour ; } cal . set ( Calendar . HOUR_OF_DAY , startHour ) ; Date startDate = cal . getTime ( ) ; cal . set ( Calendar . HOUR_OF_DAY , endHour ) ; Date endDate = cal . getTime ( ) ; if ( calendarHours == null ) { calendarHours = calendar . addCalendarHours ( day ) ; calendar . setWorkingDay ( day , true ) ; } calendarHours . addRange ( new DateRange ( startDate , endDate ) ) ; startHour = endHour ; } DateHelper . pushCalendar ( cal ) ; }
Reads the integer representation of calendar hours for a given day and populates the calendar .