public static Duration getVariance ( Task task , Date date1 , Date date2 , TimeUnit format ) { Duration variance = null ; if ( date1 != null && date2 != null ) { ProjectCalendar calendar = task . getEffectiveCalendar ( ) ; if ( calendar != null ) { variance = calendar . getWork ( date1 , date2 , format ) ; } } if ( variance == null ) { variance = Duration . getInstance ( 0 , format ) ; } return ( variance ) ; }
This utility method calculates the difference in working time between two dates given the context of a task .