code: public int getIndexByDate(Date date)
     {
        int result = -1;
        int index = 0;
  
        for (CostRateTableEntry entry : this)
        {
           if (DateHelper.compare(date, entry.getEndDate()) < 0)
           {
              result = index;
              break;
           }
           ++index;
        }
  
        return result;
     }
docs: Retrieve the index of the table entry valid for the supplied date.
  
  @param date required date
  @return cost rate table entry index