Program: 105161
Project: 105161
Buggy source:
public Calendar[] statementTime(final Calendar today,final STATEMENT_PERIODS period){
  int day_of_month=today.get(Calendar.DAY_OF_MONTH);
  int month_of_year=today.get(Calendar.MONTH);
  Calendar firstDateOfPreviousPeriod, lastDateOfPreviousPeriod;
switch (period) {
case BIMONTHLY:
    if (day_of_month < s_LAST_STATEMENT_SENT_DAYS) {
      Calendar aCalendar=(Calendar)today.clone();
      aCalendar.add(Calendar.MONTH,0);
      aCalendar.set(Calendar.DATE,1);
      aCalendar.set(Calendar.HOUR,0);
      aCalendar.set(Calendar.MINUTE,0);
      aCalendar.set(Calendar.SECOND,0);
      firstDateOfPreviousPeriod=(Calendar)aCalendar.clone();
      aCalendar.set(Calendar.DATE,15);
      lastDateOfPreviousPeriod=(Calendar)aCalendar.clone();
      return new Calendar[]{firstDateOfPreviousPeriod,lastDateOfPreviousPeriod};
    }
 else     if (day_of_month > 15 && (day_of_month - 15) < s_LAST_STATEMENT_SENT_DAYS) {
      Calendar aCalendar=(Calendar)today.clone();
      aCalendar.add(Calendar.MONTH,-1);
      aCalendar.set(Calendar.DATE,16);
      aCalendar.set(Calendar.HOUR,0);
      aCalendar.set(Calendar.MINUTE,0);
      aCalendar.set(Calendar.SECOND,0);
      firstDateOfPreviousPeriod=(Calendar)aCalendar.clone();
      aCalendar.set(Calendar.DATE,aCalendar.getActualMaximum(Calendar.DAY_OF_MONTH) + 1);
      lastDateOfPreviousPeriod=(Calendar)aCalendar.clone();
      return new Calendar[]{firstDateOfPreviousPeriod,lastDateOfPreviousPeriod};
    }
  return null;
case MONTHLY:
if (day_of_month < s_LAST_STATEMENT_SENT_DAYS) {
  Calendar aCalendar=(Calendar)today.clone();
  aCalendar.add(Calendar.MONTH,-1);
  aCalendar.set(Calendar.DATE,1);
  aCalendar.set(Calendar.HOUR,0);
  aCalendar.set(Calendar.MINUTE,0);
  aCalendar.set(Calendar.SECOND,0);
  firstDateOfPreviousPeriod=(Calendar)aCalendar.clone();
  aCalendar.set(Calendar.DATE,aCalendar.getActualMaximum(Calendar.DAY_OF_MONTH) + 1);
  lastDateOfPreviousPeriod=(Calendar)aCalendar.clone();
  return new Calendar[]{firstDateOfPreviousPeriod,lastDateOfPreviousPeriod};
}
return null;
case QUATERLY:
if (month_of_year == Calendar.JANUARY || month_of_year == Calendar.APRIL || month_of_year == Calendar.JULY || month_of_year == Calendar.OCTOBER) {
if (day_of_month < s_LAST_STATEMENT_SENT_DAYS) {
Calendar aCalendar=(Calendar)today.clone();
aCalendar.add(Calendar.MONTH,-3);
aCalendar.set(Calendar.DATE,1);
aCalendar.set(Calendar.HOUR,0);
aCalendar.set(Calendar.MINUTE,0);
aCalendar.set(Calendar.SECOND,0);
firstDateOfPreviousPeriod=(Calendar)aCalendar.clone();
aCalendar.add(Calendar.MONTH,2);
aCalendar.set(Calendar.DATE,aCalendar.getActualMaximum(Calendar.DAY_OF_MONTH) + 1);
lastDateOfPreviousPeriod=(Calendar)aCalendar.clone();
return new Calendar[]{firstDateOfPreviousPeriod,lastDateOfPreviousPeriod};
}
}
return null;
case HALFYEARLY:
if (month_of_year == Calendar.JANUARY || month_of_year == Calendar.JULY) {
if (day_of_month < s_LAST_STATEMENT_SENT_DAYS) {
Calendar aCalendar=(Calendar)today.clone();
aCalendar.add(Calendar.MONTH,-6);
aCalendar.set(Calendar.DATE,1);
aCalendar.set(Calendar.HOUR,0);
aCalendar.set(Calendar.MINUTE,0);
aCalendar.set(Calendar.SECOND,0);
firstDateOfPreviousPeriod=(Calendar)aCalendar.clone();
aCalendar.add(Calendar.MONTH,5);
aCalendar.set(Calendar.DATE,aCalendar.getActualMaximum(Calendar.DAY_OF_MONTH) + 1);
lastDateOfPreviousPeriod=(Calendar)aCalendar.clone();
return new Calendar[]{firstDateOfPreviousPeriod,lastDateOfPreviousPeriod};
}
}
return null;
case YEARLY:
if (month_of_year == Calendar.JANUARY) {
if (day_of_month < s_LAST_STATEMENT_SENT_DAYS) {
Calendar aCalendar=(Calendar)today.clone();
aCalendar.add(Calendar.MONTH,-12);
aCalendar.set(Calendar.DATE,1);
aCalendar.set(Calendar.HOUR,0);
aCalendar.set(Calendar.MINUTE,0);
aCalendar.set(Calendar.SECOND,0);
firstDateOfPreviousPeriod=(Calendar)aCalendar.clone();
aCalendar.add(Calendar.MONTH,11);
aCalendar.set(Calendar.DATE,aCalendar.getActualMaximum(Calendar.DAY_OF_MONTH) + 1);
lastDateOfPreviousPeriod=(Calendar)aCalendar.clone();
return new Calendar[]{firstDateOfPreviousPeriod,lastDateOfPreviousPeriod};
}
}
return null;
default :
break;
}
return null;
}

Fixed version (ground truth):
public Calendar[] statementTime(final Calendar today,final QuotaStatementPeriods period){
  int day_of_month=today.get(Calendar.DAY_OF_MONTH);
  int month_of_year=today.get(Calendar.MONTH);
  Calendar firstDateOfPreviousPeriod, lastDateOfPreviousPeriod;
switch (period) {
case BIMONTHLY:
    if (day_of_month < s_LAST_STATEMENT_SENT_DAYS) {
      Calendar aCalendar=(Calendar)today.clone();
      aCalendar.add(Calendar.MONTH,0);
      aCalendar.set(Calendar.DATE,1);
      aCalendar.set(Calendar.HOUR,0);
      aCalendar.set(Calendar.MINUTE,0);
      aCalendar.set(Calendar.SECOND,0);
      firstDateOfPreviousPeriod=(Calendar)aCalendar.clone();
      aCalendar.set(Calendar.DATE,15);
      lastDateOfPreviousPeriod=(Calendar)aCalendar.clone();
      return new Calendar[]{firstDateOfPreviousPeriod,lastDateOfPreviousPeriod};
    }
 else     if (day_of_month > 15 && (day_of_month - 15) < s_LAST_STATEMENT_SENT_DAYS) {
      Calendar aCalendar=(Calendar)today.clone();
      aCalendar.add(Calendar.MONTH,-1);
      aCalendar.set(Calendar.DATE,16);
      aCalendar.set(Calendar.HOUR,0);
      aCalendar.set(Calendar.MINUTE,0);
      aCalendar.set(Calendar.SECOND,0);
      firstDateOfPreviousPeriod=(Calendar)aCalendar.clone();
      aCalendar.set(Calendar.DATE,aCalendar.getActualMaximum(Calendar.DAY_OF_MONTH) + 1);
      lastDateOfPreviousPeriod=(Calendar)aCalendar.clone();
      return new Calendar[]{firstDateOfPreviousPeriod,lastDateOfPreviousPeriod};
    }
  return null;
case MONTHLY:
if (day_of_month < s_LAST_STATEMENT_SENT_DAYS) {
  Calendar aCalendar=(Calendar)today.clone();
  aCalendar.add(Calendar.MONTH,-1);
  aCalendar.set(Calendar.DATE,1);
  aCalendar.set(Calendar.HOUR,0);
  aCalendar.set(Calendar.MINUTE,0);
  aCalendar.set(Calendar.SECOND,0);
  firstDateOfPreviousPeriod=(Calendar)aCalendar.clone();
  aCalendar.set(Calendar.DATE,aCalendar.getActualMaximum(Calendar.DAY_OF_MONTH) + 1);
  lastDateOfPreviousPeriod=(Calendar)aCalendar.clone();
  return new Calendar[]{firstDateOfPreviousPeriod,lastDateOfPreviousPeriod};
}
return null;
case QUATERLY:
if (month_of_year == Calendar.JANUARY || month_of_year == Calendar.APRIL || month_of_year == Calendar.JULY || month_of_year == Calendar.OCTOBER) {
if (day_of_month < s_LAST_STATEMENT_SENT_DAYS) {
Calendar aCalendar=(Calendar)today.clone();
aCalendar.add(Calendar.MONTH,-3);
aCalendar.set(Calendar.DATE,1);
aCalendar.set(Calendar.HOUR,0);
aCalendar.set(Calendar.MINUTE,0);
aCalendar.set(Calendar.SECOND,0);
firstDateOfPreviousPeriod=(Calendar)aCalendar.clone();
aCalendar.add(Calendar.MONTH,2);
aCalendar.set(Calendar.DATE,aCalendar.getActualMaximum(Calendar.DAY_OF_MONTH) + 1);
lastDateOfPreviousPeriod=(Calendar)aCalendar.clone();
return new Calendar[]{firstDateOfPreviousPeriod,lastDateOfPreviousPeriod};
}
}
return null;
case HALFYEARLY:
if (month_of_year == Calendar.JANUARY || month_of_year == Calendar.JULY) {
if (day_of_month < s_LAST_STATEMENT_SENT_DAYS) {
Calendar aCalendar=(Calendar)today.clone();
aCalendar.add(Calendar.MONTH,-6);
aCalendar.set(Calendar.DATE,1);
aCalendar.set(Calendar.HOUR,0);
aCalendar.set(Calendar.MINUTE,0);
aCalendar.set(Calendar.SECOND,0);
firstDateOfPreviousPeriod=(Calendar)aCalendar.clone();
aCalendar.add(Calendar.MONTH,5);
aCalendar.set(Calendar.DATE,aCalendar.getActualMaximum(Calendar.DAY_OF_MONTH) + 1);
lastDateOfPreviousPeriod=(Calendar)aCalendar.clone();
return new Calendar[]{firstDateOfPreviousPeriod,lastDateOfPreviousPeriod};
}
}
return null;
case YEARLY:
if (month_of_year == Calendar.JANUARY) {
if (day_of_month < s_LAST_STATEMENT_SENT_DAYS) {
Calendar aCalendar=(Calendar)today.clone();
aCalendar.add(Calendar.MONTH,-12);
aCalendar.set(Calendar.DATE,1);
aCalendar.set(Calendar.HOUR,0);
aCalendar.set(Calendar.MINUTE,0);
aCalendar.set(Calendar.SECOND,0);
firstDateOfPreviousPeriod=(Calendar)aCalendar.clone();
aCalendar.add(Calendar.MONTH,11);
aCalendar.set(Calendar.DATE,aCalendar.getActualMaximum(Calendar.DAY_OF_MONTH) + 1);
lastDateOfPreviousPeriod=(Calendar)aCalendar.clone();
return new Calendar[]{firstDateOfPreviousPeriod,lastDateOfPreviousPeriod};
}
}
return null;
default :
break;
}
return null;
}