Program: 50749
Project: 50749
Buggy source:
/** 
 * This method calculates the number of milliseconds of working time during the supplied timestamps.
 * @param from
 * @param to
 * @return
 */
public long getWorkingDuration(long from,long to){
  long ret=0;
  if (to > from) {
    java.util.Calendar fromDateTime=createCalendar(from);
    do {
      WorkingDay wd=findWorkingDay(fromDateTime);
      if (wd != null) {
        if (!isExcluded(fromDateTime)) {
          if (wd.getStartHour() > fromDateTime.get(java.util.Calendar.HOUR_OF_DAY)) {
            fromDateTime.set(java.util.Calendar.HOUR_OF_DAY,wd.getStartHour());
            fromDateTime.set(java.util.Calendar.MINUTE,wd.getStartMinute());
          }
 else           if (wd.getStartHour() == fromDateTime.get(java.util.Calendar.HOUR_OF_DAY) && wd.getStartMinute() > fromDateTime.get(java.util.Calendar.MINUTE)) {
            fromDateTime.set(java.util.Calendar.MINUTE,wd.getStartMinute());
          }
          long startOfDay=fromDateTime.getTimeInMillis();
          fromDateTime.set(java.util.Calendar.HOUR_OF_DAY,wd.getEndHour());
          fromDateTime.set(java.util.Calendar.MINUTE,wd.getEndMinute());
          long endOfDay=fromDateTime.getTimeInMillis();
          if (endOfDay > to) {
            endOfDay=to;
          }
          ret+=(endOfDay - startOfDay);
        }
      }
      fromDateTime=createCalendar(fromDateTime.getTimeInMillis() + (24 * 60 * 60* 1000));
      fromDateTime.set(java.util.Calendar.HOUR_OF_DAY,0);
      fromDateTime.set(java.util.Calendar.MINUTE,0);
    }
 while (fromDateTime.getTimeInMillis() < to);
  }
  return (ret);
}

Fixed version (ground truth):
/** 
 * This method calculates the number of milliseconds of working time during the supplied timestamps.
 * @param from The from timestamp
 * @param to The to timestamp
 * @return The duration in milliseconds
 */
public long getWorkingDuration(long from,long to){
  long ret=0;
  if (to > from) {
    java.util.Calendar fromDateTime=createCalendar(from);
    do {
      WorkingDay wd=findWorkingDay(fromDateTime);
      if (wd != null) {
        if (!isExcluded(fromDateTime)) {
          if (wd.getStartHour() > fromDateTime.get(java.util.Calendar.HOUR_OF_DAY)) {
            fromDateTime.set(java.util.Calendar.HOUR_OF_DAY,wd.getStartHour());
            fromDateTime.set(java.util.Calendar.MINUTE,wd.getStartMinute());
          }
 else           if (wd.getStartHour() == fromDateTime.get(java.util.Calendar.HOUR_OF_DAY) && wd.getStartMinute() > fromDateTime.get(java.util.Calendar.MINUTE)) {
            fromDateTime.set(java.util.Calendar.MINUTE,wd.getStartMinute());
          }
          long startOfDay=fromDateTime.getTimeInMillis();
          fromDateTime.set(java.util.Calendar.HOUR_OF_DAY,wd.getEndHour());
          fromDateTime.set(java.util.Calendar.MINUTE,wd.getEndMinute());
          long endOfDay=fromDateTime.getTimeInMillis();
          if (endOfDay > to) {
            endOfDay=to;
          }
          ret+=(endOfDay - startOfDay);
        }
      }
      fromDateTime=createCalendar(fromDateTime.getTimeInMillis() + (24 * 60 * 60* 1000));
      fromDateTime.set(java.util.Calendar.HOUR_OF_DAY,0);
      fromDateTime.set(java.util.Calendar.MINUTE,0);
    }
 while (fromDateTime.getTimeInMillis() < to);
  }
  return (ret);
}