Program: 128775
Project: 128775
Buggy source:
/** 
 * get part of date. like YEAR, MONTH, HOUR, or DAY_OF_WEEK, WEEK_OF_MONTH, WEEK_OF_YEAR, TIMEZONE and so on
 * @param partName which part to get.
 * @param date the date value.
 * @return the specified part value.{talendTypes} Integer {Category} TalendDate {param} string("DAY_OF_WEEK") partName : which part to get {param} date(TalendDate.parseDate("yyyy-MM-dd", "2010-12-26")) date : the date value {example} getPartOfDate("DAY_OF_WEEK", TalendDate.parseDate("yyyy-MM-dd", "2010-12-26")) #
 */
public static int getPartOfDate(String partName,Date date){
  if (partName == null || date == null)   return 0;
  int ret=0;
  String[] fieldsName={"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str"};
  java.util.List<String> filedsList=java.util.Arrays.asList(fieldsName);
  Calendar c=Calendar.getInstance();
  c.setTime(date);
switch (filedsList.indexOf(partName)) {
case 0:
    ret=c.get(Calendar.YEAR);
  break;
case 1:
ret=c.get(Calendar.MONTH);
break;
case 2:
ret=c.get(Calendar.HOUR);
break;
case 3:
ret=c.get(Calendar.MINUTE);
break;
case 4:
ret=c.get(Calendar.SECOND);
break;
case 5:
ret=c.get(Calendar.DAY_OF_WEEK);
break;
case 6:
ret=c.get(Calendar.DAY_OF_MONTH);
break;
case 7:
ret=c.get(Calendar.DAY_OF_YEAR);
break;
case 8:
ret=c.get(Calendar.WEEK_OF_MONTH);
break;
case 9:
ret=c.get(Calendar.DAY_OF_WEEK_IN_MONTH);
break;
case 10:
ret=c.get(Calendar.WEEK_OF_YEAR);
break;
case 11:
ret=(c.get(Calendar.ZONE_OFFSET)) / (1000 * 60 * 60);
break;
default :
break;
}
return ret;
}

Fixed version (ground truth):
/** 
 * get part of date. like YEAR, MONTH, HOUR, or DAY_OF_WEEK, WEEK_OF_MONTH, WEEK_OF_YEAR, TIMEZONE and so on
 * @param partName which part to get.
 * @param date the date value.
 * @return the specified part value.{talendTypes} Integer {Category} TalendDate {param} string("DAY_OF_WEEK") partName : which part to get {param} date(TalendDate.parseDate("yyyy-MM-dd", "2010-12-26")) date : the date value {example} getPartOfDate("DAY_OF_WEEK", TalendDate.parseDate("yyyy-MM-dd", "2010-12-26")) #
 */
public static int getPartOfDate(String partName,Date date){
  if (partName == null || date == null) {
    return 0;
  }
  int ret=0;
  String[] fieldsName={"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str"};
  java.util.List<String> filedsList=java.util.Arrays.asList(fieldsName);
  Calendar c=Calendar.getInstance();
  c.setTime(date);
switch (filedsList.indexOf(partName)) {
case 0:
    ret=c.get(Calendar.YEAR);
  break;
case 1:
ret=c.get(Calendar.MONTH);
break;
case 2:
ret=c.get(Calendar.HOUR);
break;
case 3:
ret=c.get(Calendar.MINUTE);
break;
case 4:
ret=c.get(Calendar.SECOND);
break;
case 5:
ret=c.get(Calendar.DAY_OF_WEEK);
break;
case 6:
ret=c.get(Calendar.DAY_OF_MONTH);
break;
case 7:
ret=c.get(Calendar.DAY_OF_YEAR);
break;
case 8:
ret=c.get(Calendar.WEEK_OF_MONTH);
break;
case 9:
ret=c.get(Calendar.DAY_OF_WEEK_IN_MONTH);
break;
case 10:
ret=c.get(Calendar.WEEK_OF_YEAR);
break;
case 11:
ret=(c.get(Calendar.ZONE_OFFSET)) / (1000 * 60 * 60);
break;
default :
break;
}
return ret;
}