code: private long getTime(Date start, Date end)
     {
        long total = 0;
        if (start != null && end != null)
        {
           Date startTime = DateHelper.getCanonicalTime(start);
           Date endTime = DateHelper.getCanonicalTime(end);
  
           Date startDay = DateHelper.getDayStartDate(start);
           Date finishDay = DateHelper.getDayStartDate(end);
  
           //
           // Handle the case where the end of the range is at midnight -
           // this will show up as the start and end days not matching
           //
           if (startDay.getTime() != finishDay.getTime())
           {            
              endTime = DateHelper.addDays(endTime, 1);
           }
  
           total = (endTime.getTime() - startTime.getTime());
        }
        return (total);
     }
docs: Retrieves the amount of time between two date time values. Note that
  these values are converted into canonical values to remove the
  date component.
  
  @param start start time
  @param end end time
  @return length of time