code: private long getTotalTime(ProjectCalendarDateRanges exception, Date date, boolean after)
     {
        long currentTime = DateHelper.getCanonicalTime(date).getTime();
        long total = 0;
        for (DateRange range : exception)
        {
           total += getTime(range.getStart(), range.getEnd(), currentTime, after);
        }
        return (total);
     }
docs: Retrieves the amount of time represented by a calendar exception
  before or after an intersection point.
  
  @param exception calendar exception
  @param date intersection time
  @param after true to report time after intersection, false to report time before
  @return length of time in milliseconds