Program: 99323
Project: 99323
Buggy source:
/** 
 * Determine the correct ResultsPartitioner to use given the SearchResults search range, and use that to break the SearchResults into partitions.
 * @param results
 * @param wbRequest 
 * @return ArrayList of ResultsPartition objects
 */
public static ArrayList<ResultsPartition> get(SearchResults results,WaybackRequest wbRequest){
  String rsd=results.getFilter(WaybackConstants.REQUEST_START_DATE);
  String red=results.getFilter(WaybackConstants.REQUEST_END_DATE);
  Date startDate=new Date();
  Date endDate=new Date();
  try {
    startDate=ArchiveUtils.parse14DigitDate(rsd);
    endDate=ArchiveUtils.parse14DigitDate(red);
  }
 catch (  ParseException e) {
    e.printStackTrace();
  }
  long msSpanned=endDate.getTime() - startDate.getTime();
  int secsSpanned=(int)Math.ceil(msSpanned / 1000);
  ResultsPartitioner partitioner=null;
  for (int i=0; i < partitioners.length; i++) {
    partitioner=partitioners[i];
    if (partitioner.maxSecondsSpanned() >= secsSpanned) {
      break;
    }
  }
  ArrayList<ResultsPartition> partitions=new ArrayList<ResultsPartition>();
  Calendar startCal=partitioner.dateStrToCalendar(rsd);
  Calendar lastCal=partitioner.dateStrToCalendar(red);
  partitioner.alignStart(startCal);
  Calendar endCal=partitioner.incrementPartition(startCal,1);
  while (true) {
    String startDateStr=ArchiveUtils.get14DigitDate(startCal.getTime());
    String endDateStr=ArchiveUtils.get14DigitDate(endCal.getTime());
    String title=partitioner.rangeToTitle(startCal,endCal,wbRequest);
    ResultsPartition partition=new ResultsPartition(startDateStr,endDateStr,title);
    partition.filter(results);
    partitions.add(partition);
    if (endCal.after(lastCal)) {
      break;
    }
    startCal=endCal;
    endCal=partitioner.incrementPartition(startCal,1);
  }
  return partitions;
}

Fixed version (ground truth):
/** 
 * Determine the correct ResultsPartitioner to use given the SearchResults search range, and use that to break the SearchResults into partitions.
 * @param results
 * @param wbRequest 
 * @return ArrayList of ResultsPartition objects
 */
public static ArrayList<ResultsPartition> get(SearchResults results,WaybackRequest wbRequest){
  String rsd=results.getFilter(WaybackConstants.REQUEST_START_DATE);
  String red=results.getFilter(WaybackConstants.REQUEST_END_DATE);
  Date startDate=Timestamp.parseBefore(rsd).getDate();
  Date endDate=Timestamp.parseAfter(red).getDate();
  long msSpanned=endDate.getTime() - startDate.getTime();
  int secsSpanned=(int)Math.ceil(msSpanned / 1000);
  ResultsPartitioner partitioner=null;
  for (int i=0; i < partitioners.length; i++) {
    partitioner=partitioners[i];
    if (partitioner.maxSecondsSpanned() >= secsSpanned) {
      break;
    }
  }
  ArrayList<ResultsPartition> partitions=new ArrayList<ResultsPartition>();
  Calendar startCal=partitioner.dateStrToCalendar(rsd);
  Calendar lastCal=partitioner.dateStrToCalendar(red);
  partitioner.alignStart(startCal);
  Calendar endCal=partitioner.incrementPartition(startCal,1);
  while (true) {
    String startDateStr=ArchiveUtils.get14DigitDate(startCal.getTime());
    String endDateStr=ArchiveUtils.get14DigitDate(endCal.getTime());
    String title=partitioner.rangeToTitle(startCal,endCal,wbRequest);
    ResultsPartition partition=new ResultsPartition(startDateStr,endDateStr,title);
    partition.filter(results);
    partitions.add(partition);
    if (endCal.after(lastCal)) {
      break;
    }
    startCal=endCal;
    endCal=partitioner.incrementPartition(startCal,1);
  }
  return partitions;
}