Program: 142440
Project: 142440
Buggy source:
/** 
 * This method creates a   {@link Date} object from a {@link String} representation with respect to year, month and day.The provided String is expected to be exactly 8 characters long and encoded as follows: YYYYMMDD. If the String parts for month or day contain non-numeric characters, they will be handled according to the second provided parameter: -1: the minimum possible value will be chosen 0: a NumberFormatException will be thrown 1: the maximum possible value will be chosen Well formatted date strings will not be checked for validity, e.g. december 34th would not be discarded.
 * @param dateString the date encoded as follows: YYYYMMDD
 * @param handleNonNumericCharacters determine how non-numeric characters will be handled
 * @return a {@link Date} object
 */
public static Date getDate(String dateString,byte handleNonNumericCharacters){
  if (dateString == null) {
    throw new NullPointerException("String_Node_Str");
  }
  if (dateString.length() != 8) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  Calendar calendar=Calendar.getInstance();
  int year=Integer.parseInt(dateString.substring(0,4));
  calendar.set(Calendar.YEAR,year);
  int month, day;
  try {
    month=Integer.parseInt(dateString.substring(4,6));
  }
 catch (  NumberFormatException e) {
switch (handleNonNumericCharacters) {
case -1:
      month=Calendar.JANUARY;
    break;
case 0:
  throw e;
case 1:
month=Calendar.DECEMBER;
break;
default :
throw new IllegalArgumentException("String_Node_Str");
}
}
calendar.set(Calendar.MONTH,month);
try {
day=Integer.parseInt(dateString.substring(6,8));
}
 catch (NumberFormatException e) {
switch (handleNonNumericCharacters) {
case -1:
day=1;
break;
case 0:
throw e;
case 1:
day=calendar.getActualMaximum(Calendar.DATE);
break;
default :
throw new IllegalArgumentException("String_Node_Str");
}
}
calendar.set(Calendar.DATE,day);
calendar.set(Calendar.HOUR_OF_DAY,0);
calendar.set(Calendar.MINUTE,0);
calendar.set(Calendar.SECOND,0);
calendar.set(Calendar.MILLISECOND,0);
return calendar.getTime();
}

Fixed version (ground truth):
/** 
 * This method creates a   {@link Date} object from a {@link String} representation with respect to year, month and day.The provided String is expected to be exactly 8 characters long and encoded as follows: YYYYMMDD. If the String parts for month or day contain non-numeric characters, they will be handled according to the second provided parameter: -1: the minimum possible value will be chosen 0: a NumberFormatException will be thrown 1: the maximum possible value will be chosen Well formatted date strings will not be checked for validity, e.g. december 34th would not be discarded.
 * @param dateString the date encoded as follows: YYYYMMDD
 * @param handleNonNumericCharacters determine how non-numeric characters will be handled
 * @return a {@link Date} object
 */
public static Date getDate(String dateString,byte handleNonNumericCharacters){
  if (dateString == null) {
    throw new NullPointerException("String_Node_Str");
  }
  if (dateString.length() != 8) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  Calendar calendar=Calendar.getInstance();
  int year=Integer.parseInt(dateString.substring(0,4));
  calendar.set(Calendar.YEAR,year);
  int month, day;
  try {
    month=Integer.parseInt(dateString.substring(4,6));
  }
 catch (  NumberFormatException e) {
switch (handleNonNumericCharacters) {
case -1:
      month=Calendar.JANUARY;
    break;
case 0:
  throw e;
case 1:
month=Calendar.DECEMBER;
break;
default :
throw new IllegalArgumentException("String_Node_Str");
}
}
calendar.set(Calendar.MONTH,month - 1);
try {
day=Integer.parseInt(dateString.substring(6,8));
}
 catch (NumberFormatException e) {
switch (handleNonNumericCharacters) {
case -1:
day=1;
break;
case 0:
throw e;
case 1:
day=calendar.getActualMaximum(Calendar.DATE);
break;
default :
throw new IllegalArgumentException("String_Node_Str");
}
}
calendar.set(Calendar.DATE,day);
calendar.set(Calendar.HOUR_OF_DAY,0);
calendar.set(Calendar.MINUTE,0);
calendar.set(Calendar.SECOND,0);
calendar.set(Calendar.MILLISECOND,0);
return calendar.getTime();
}