Program: 71176
Project: 71176
Buggy source:
/** 
 * 设置日期控件默认选中的时间
 * @param time date
 */
public void setSelectedTime(Date time){
  Calendar tempCalendar=Calendar.getInstance();
  tempCalendar.setTime(time);
  int y=tempCalendar.get(Calendar.YEAR);
  int m=tempCalendar.get(Calendar.MONTH) + 1;
  int d=tempCalendar.get(Calendar.DAY_OF_MONTH);
  int h=tempCalendar.get(Calendar.HOUR_OF_DAY);
  int mm=tempCalendar.get(Calendar.MINUTE);
  yearPicker.setSelected(String.valueOf(y));
  selectedCalender.set(Calendar.YEAR,y);
  if (curShowType.value >= ShowType.MONTH.value) {
    months.clear();
    if (y == startYear) {
      for (int i=startMonth; i <= MAX_MONTH; i++) {
        months.add(formatTimeUnit(i));
      }
    }
 else     if (y == endYear) {
      for (int i=1; i <= endMonth; i++) {
        months.add(formatTimeUnit(i));
      }
    }
 else {
      for (int i=1; i <= MAX_MONTH; i++) {
        months.add(formatTimeUnit(i));
      }
    }
    monthPicker.setData(months);
    monthPicker.setSelected(formatTimeUnit(m));
    selectedCalender.set(Calendar.MONTH,m - 1);
    executeAnimator(monthPicker);
  }
  if (curShowType.value >= ShowType.DAY.value) {
    days.clear();
    if (y == startYear && m == startMonth) {
      for (int i=startDay; i <= selectedCalender.getActualMaximum(Calendar.DAY_OF_MONTH); i++) {
        days.add(formatTimeUnit(i));
      }
    }
 else     if (y == endYear && m == endMonth) {
      for (int i=1; i <= endDay; i++) {
        days.add(formatTimeUnit(i));
      }
    }
 else {
      for (int i=1; i <= selectedCalender.getActualMaximum(Calendar.DAY_OF_MONTH); i++) {
        days.add(formatTimeUnit(i));
      }
    }
    dayPicker.setData(days);
    dayPicker.setSelected(formatTimeUnit(d));
    selectedCalender.set(Calendar.DAY_OF_MONTH,d);
    executeAnimator(dayPicker);
  }
  if (curShowType.value >= ShowType.HOUR.value) {
    hours.clear();
    int selectedDay=selectedCalender.get(Calendar.DAY_OF_MONTH);
    if (y == startYear && m == startMonth && selectedDay == startDay) {
      for (int i=startHour; i <= MAX_HOUR; i++) {
        hours.add(formatTimeUnit(i));
      }
    }
 else     if (y == endYear && m == endMonth && selectedDay == endDay) {
      for (int i=MIN_HOUR; i <= endHour; i++) {
        hours.add(formatTimeUnit(i));
      }
    }
 else {
      for (int i=MIN_HOUR; i <= MAX_HOUR; i++) {
        hours.add(formatTimeUnit(i));
      }
    }
    hourPicker.setData(hours);
    hourPicker.setSelected(formatTimeUnit(h));
    selectedCalender.set(Calendar.HOUR_OF_DAY,h);
    executeAnimator(hourPicker);
  }
  if (curShowType.value >= ShowType.MINUTE.value) {
    minutes.clear();
    int selectedDay=selectedCalender.get(Calendar.DAY_OF_MONTH);
    int selectedHour=selectedCalender.get(Calendar.HOUR_OF_DAY);
    if (y == startYear && m == startMonth && selectedDay == startDay && selectedHour == startHour) {
      for (int i=startMinute; i <= MAX_MINUTE; i++) {
        minutes.add(formatTimeUnit(i));
      }
    }
 else     if (y == endYear && m == endMonth && selectedDay == endDay && selectedHour == endHour) {
      for (int i=MIN_MINUTE; i <= endMinute; i++) {
        minutes.add(formatTimeUnit(i));
      }
    }
 else {
      for (int i=MIN_MINUTE; i <= MAX_MINUTE; i++) {
        minutes.add(formatTimeUnit(i));
      }
    }
    minutePicker.setData(minutes);
    minutePicker.setSelected(formatTimeUnit(mm));
    selectedCalender.set(Calendar.MINUTE,mm);
    executeAnimator(minutePicker);
  }
  executeScroll();
}

Fixed version (ground truth):
/** 
 * 设置日期控件默认选中的时间
 * @param time date
 */
public void setSelectedTime(Date time){
  Calendar tempCalendar=Calendar.getInstance();
  tempCalendar.setTime(time);
  int y=tempCalendar.get(Calendar.YEAR);
  int m=tempCalendar.get(Calendar.MONTH) + 1;
  int d=tempCalendar.get(Calendar.DAY_OF_MONTH);
  int h=tempCalendar.get(Calendar.HOUR_OF_DAY);
  int mm=tempCalendar.get(Calendar.MINUTE);
  yearPicker.setSelected(String.valueOf(y));
  selectedCalender.set(Calendar.YEAR,y);
  if (curShowType.value >= ShowType.MONTH.value) {
    months.clear();
    if (startYear == endYear) {
      for (int i=1; i <= endMonth; i++) {
        months.add(formatTimeUnit(i));
      }
    }
 else {
      if (y == startYear) {
        for (int i=startMonth; i <= MAX_MONTH; i++) {
          months.add(formatTimeUnit(i));
        }
      }
 else       if (y == endYear) {
        for (int i=1; i <= endMonth; i++) {
          months.add(formatTimeUnit(i));
        }
      }
 else {
        for (int i=1; i <= MAX_MONTH; i++) {
          months.add(formatTimeUnit(i));
        }
      }
    }
    monthPicker.setData(months);
    monthPicker.setSelected(formatTimeUnit(m));
    selectedCalender.set(Calendar.MONTH,m - 1);
    executeAnimator(monthPicker);
  }
  if (curShowType.value >= ShowType.DAY.value) {
    days.clear();
    if (y == startYear && m == startMonth) {
      for (int i=startDay; i <= selectedCalender.getActualMaximum(Calendar.DAY_OF_MONTH); i++) {
        days.add(formatTimeUnit(i));
      }
    }
 else     if (y == endYear && m == endMonth) {
      for (int i=1; i <= endDay; i++) {
        days.add(formatTimeUnit(i));
      }
    }
 else {
      for (int i=1; i <= selectedCalender.getActualMaximum(Calendar.DAY_OF_MONTH); i++) {
        days.add(formatTimeUnit(i));
      }
    }
    dayPicker.setData(days);
    dayPicker.setSelected(formatTimeUnit(d));
    selectedCalender.set(Calendar.DAY_OF_MONTH,d);
    executeAnimator(dayPicker);
  }
  if (curShowType.value >= ShowType.HOUR.value) {
    hours.clear();
    int selectedDay=selectedCalender.get(Calendar.DAY_OF_MONTH);
    if (y == startYear && m == startMonth && selectedDay == startDay) {
      for (int i=startHour; i <= MAX_HOUR; i++) {
        hours.add(formatTimeUnit(i));
      }
    }
 else     if (y == endYear && m == endMonth && selectedDay == endDay) {
      for (int i=MIN_HOUR; i <= endHour; i++) {
        hours.add(formatTimeUnit(i));
      }
    }
 else {
      for (int i=MIN_HOUR; i <= MAX_HOUR; i++) {
        hours.add(formatTimeUnit(i));
      }
    }
    hourPicker.setData(hours);
    hourPicker.setSelected(formatTimeUnit(h));
    selectedCalender.set(Calendar.HOUR_OF_DAY,h);
    executeAnimator(hourPicker);
  }
  if (curShowType.value >= ShowType.MINUTE.value) {
    minutes.clear();
    int selectedDay=selectedCalender.get(Calendar.DAY_OF_MONTH);
    int selectedHour=selectedCalender.get(Calendar.HOUR_OF_DAY);
    if (y == startYear && m == startMonth && selectedDay == startDay && selectedHour == startHour) {
      for (int i=startMinute; i <= MAX_MINUTE; i++) {
        minutes.add(formatTimeUnit(i));
      }
    }
 else     if (y == endYear && m == endMonth && selectedDay == endDay && selectedHour == endHour) {
      for (int i=MIN_MINUTE; i <= endMinute; i++) {
        minutes.add(formatTimeUnit(i));
      }
    }
 else {
      for (int i=MIN_MINUTE; i <= MAX_MINUTE; i++) {
        minutes.add(formatTimeUnit(i));
      }
    }
    minutePicker.setData(minutes);
    minutePicker.setSelected(formatTimeUnit(mm));
    selectedCalender.set(Calendar.MINUTE,mm);
    executeAnimator(minutePicker);
  }
  executeScroll();
}