private void addDateRange ( ProjectCalendarHours hours , Date start , Date end ) { if ( start != null && end != null ) { Calendar cal = DateHelper . popCalendar ( end ) ; // If the time ends on midnight, the date should be the next day. Otherwise problems occur. if ( cal . get ( Calendar . HOUR_OF_DAY ) == 0 && cal . get ( Calendar . MINUTE ) == 0 && cal . get ( Calendar . SECOND ) == 0 && cal . get ( Calendar . MILLISECOND ) == 0 ) { cal . add ( Calendar . DAY_OF_YEAR , 1 ) ; } end = cal . getTime ( ) ; DateHelper . pushCalendar ( cal ) ; hours . addRange ( new DateRange ( start , end ) ) ; } }
Get a date range that correctly handles the case where the end time is midnight . In this instance the end time should be the start of the next day .