Program: 66040
Project: 66040
Buggy source:
/** 
 * translate the TimeMember.values to Calendar return the base level("year","month","day"...)
 * @param cal
 * @param levelTypes
 * @param values
 * @return
 */
protected String translateToCal(Calendar cal,String[] levelTypes,int[] values){
  String type="String_Node_Str";
  int dayOfWeek=1;
  for (int i=0; i < values.length; i++) {
    if (levelTypes[i].equals(TimeMember.TIME_LEVEL_TYPE_YEAR)) {
      cal.set(Calendar.YEAR,values[i]);
      type=YEAR;
    }
 else     if (levelTypes[i].equals(TimeMember.TIME_LEVEL_TYPE_QUARTER)) {
      cal.set(Calendar.MONTH,values[i] * 3 - 1);
      type=QUARTER;
    }
 else     if (levelTypes[i].equals(TimeMember.TIME_LEVEL_TYPE_MONTH)) {
      cal.set(Calendar.MONTH,values[i] - 1);
      type=MONTH;
    }
 else     if (levelTypes[i].equals(TimeMember.TIME_LEVEL_TYPE_WEEK_OF_MONTH)) {
      if (referenceDate != null && referenceDate.getDate() != null) {
        dayOfWeek=referenceDate.getDate().getDay();
        cal.set(Calendar.DAY_OF_WEEK,dayOfWeek + 1);
      }
 else {
        int year_woy=cal.get(Calendar.YEAR_WOY);
        int year=cal.get(Calendar.YEAR);
        if (year_woy < year) {
          cal.add(Calendar.DAY_OF_WEEK,7);
        }
        cal.set(Calendar.DAY_OF_WEEK,1);
      }
      cal.set(Calendar.WEEK_OF_MONTH,values[i]);
      type=WEEK;
    }
 else     if (levelTypes[i].equals(TimeMember.TIME_LEVEL_TYPE_WEEK_OF_YEAR)) {
      if (referenceDate != null && referenceDate.getDate() != null) {
        dayOfWeek=referenceDate.getDate().getDay();
        cal.set(Calendar.DAY_OF_WEEK,dayOfWeek + 1);
      }
 else {
        int year_woy=cal.get(Calendar.YEAR_WOY);
        int year=cal.get(Calendar.YEAR);
        if (year_woy < year) {
          cal.add(Calendar.DAY_OF_WEEK,7);
        }
        cal.set(Calendar.DAY_OF_WEEK,1);
      }
      cal.set(Calendar.WEEK_OF_YEAR,values[i]);
      type=WEEK;
    }
 else     if (levelTypes[i].equals(TimeMember.TIME_LEVEL_TYPE_DAY_OF_WEEK)) {
      cal.get(Calendar.DAY_OF_WEEK);
      cal.set(Calendar.DAY_OF_WEEK,values[i]);
      type=DAY;
    }
 else     if (levelTypes[i].equals(TimeMember.TIME_LEVEL_TYPE_DAY_OF_MONTH)) {
      cal.set(Calendar.DAY_OF_MONTH,values[i]);
      type=DAY;
    }
 else     if (levelTypes[i].equals(TimeMember.TIME_LEVEL_TYPE_DAY_OF_YEAR)) {
      cal.set(Calendar.DAY_OF_YEAR,values[i]);
      type=DAY;
    }
  }
  this.referenceDate=new ReferenceDate(cal.getTime());
  return type;
}

Fixed version (ground truth):
/** 
 * translate the TimeMember.values to Calendar return the base level("year","month","day"...)
 * @param cal
 * @param levelTypes
 * @param values
 * @return
 */
protected String translateToCal(Calendar cal,String[] levelTypes,int[] values){
  String type="String_Node_Str";
  int dayOfWeek=1;
  int month=1;
  for (int i=0; i < values.length; i++) {
    if (levelTypes[i].equals(TimeMember.TIME_LEVEL_TYPE_YEAR)) {
      cal.set(Calendar.YEAR,values[i]);
      type=YEAR;
    }
 else     if (levelTypes[i].equals(TimeMember.TIME_LEVEL_TYPE_QUARTER)) {
      cal.set(Calendar.MONTH,values[i] * 3 - 1);
      type=QUARTER;
    }
 else     if (levelTypes[i].equals(TimeMember.TIME_LEVEL_TYPE_MONTH)) {
      cal.set(Calendar.MONTH,values[i] - 1);
      type=MONTH;
      month=values[i] - 1;
    }
 else     if (levelTypes[i].equals(TimeMember.TIME_LEVEL_TYPE_WEEK_OF_MONTH)) {
      if (referenceDate != null && referenceDate.getDate() != null) {
        dayOfWeek=referenceDate.getDate().getDay();
        cal.set(Calendar.DAY_OF_WEEK,dayOfWeek + 1);
      }
 else {
        int year_woy=cal.get(Calendar.YEAR_WOY);
        int year=cal.get(Calendar.YEAR);
        if (year_woy < year) {
          cal.add(Calendar.DAY_OF_WEEK,7);
        }
        cal.set(Calendar.DAY_OF_WEEK,1);
      }
      cal.set(Calendar.WEEK_OF_MONTH,values[i]);
      setAcrossMonthWeekDay(cal,month);
      type=WEEK;
    }
 else     if (levelTypes[i].equals(TimeMember.TIME_LEVEL_TYPE_WEEK_OF_YEAR)) {
      if (referenceDate != null && referenceDate.getDate() != null) {
        dayOfWeek=referenceDate.getDate().getDay();
        cal.set(Calendar.DAY_OF_WEEK,dayOfWeek + 1);
      }
 else {
        int year_woy=cal.get(Calendar.YEAR_WOY);
        int year=cal.get(Calendar.YEAR);
        if (year_woy < year) {
          cal.add(Calendar.DAY_OF_WEEK,7);
        }
        cal.set(Calendar.DAY_OF_WEEK,1);
      }
      cal.set(Calendar.WEEK_OF_YEAR,values[i]);
      setAcrossMonthWeekDay(cal,month);
      type=WEEK;
    }
 else     if (levelTypes[i].equals(TimeMember.TIME_LEVEL_TYPE_DAY_OF_WEEK)) {
      cal.get(Calendar.DAY_OF_WEEK);
      cal.set(Calendar.DAY_OF_WEEK,values[i]);
      type=DAY;
    }
 else     if (levelTypes[i].equals(TimeMember.TIME_LEVEL_TYPE_DAY_OF_MONTH)) {
      cal.set(Calendar.DAY_OF_MONTH,values[i]);
      type=DAY;
    }
 else     if (levelTypes[i].equals(TimeMember.TIME_LEVEL_TYPE_DAY_OF_YEAR)) {
      cal.set(Calendar.DAY_OF_YEAR,values[i]);
      type=DAY;
    }
  }
  this.referenceDate=new ReferenceDate(cal.getTime());
  return type;
}