Program: 72639
Project: 72639
Buggy source:
/** 
 * Construct a date token with all tokens present. If a token for the long value is present, use this token and time zone as well as precision. Otherwise use tokens on other inputs to create ports.
 * @exception IllegalActionException If there is no director.
 */
@Override public void fire() throws IllegalActionException {
  super.fire();
  DateToken dateToken=null;
  int datePrecision=DateToken.PRECISION_MILLISECOND;
  if (timeAsLong.connectedPortList().size() > 0 && timeAsLong.hasToken(0)) {
    long timeAsLongValue=1l;
    timeAsLongValue=((LongToken)timeAsLong.get(0)).longValue();
    String precisionValue="String_Node_Str";
    precisionValue=((StringToken)precision.getToken()).stringValue();
    if (precisionValue.equals("String_Node_Str")) {
      datePrecision=DateToken.PRECISION_SECOND;
    }
    if (precisionValue.equals("String_Node_Str")) {
      datePrecision=DateToken.PRECISION_MILLISECOND;
    }
    if (precisionValue.equals("String_Node_Str")) {
      datePrecision=DateToken.PRECISION_MICROSECOND;
    }
    if (precisionValue.equals("String_Node_Str")) {
      datePrecision=DateToken.PRECISION_NANOSECOND;
    }
 else {
      datePrecision=DateToken.PRECISION_MILLISECOND;
    }
    String timeZoneValue=TimeZone.getDefault().getID();
    if ((timeZone.connectedPortList().size() > 0) && timeZone.hasToken(0)) {
      timeZoneValue=((StringToken)timeZone.get(0)).stringValue();
    }
    dateToken=new DateToken(timeAsLongValue,datePrecision,TimeZone.getTimeZone(timeZoneValue));
  }
 else {
    int yearValue=1970;
    if (year.connectedPortList().size() > 0 && year.hasToken(0)) {
      yearValue=((IntToken)year.get(0)).intValue();
    }
    int monthValue=1;
    if (month.connectedPortList().size() > 0 && month.hasToken(0)) {
      monthValue=((IntToken)month.get(0)).intValue();
    }
    int dayValue=1;
    if (day.connectedPortList().size() > 0 && day.hasToken(0)) {
      dayValue=((IntToken)day.get(0)).intValue();
    }
    int hourValue=0;
    if (hour.connectedPortList().size() > 0 && hour.hasToken(0)) {
      hourValue=((IntToken)hour.get(0)).intValue();
    }
    int minuteValue=0;
    if (minute.connectedPortList().size() > 0 && minute.hasToken(0)) {
      minuteValue=((IntToken)minute.get(0)).intValue();
    }
    int secondValue=0;
    if (second.connectedPortList().size() > 0 && second.hasToken(0)) {
      secondValue=((IntToken)second.get(0)).intValue();
      datePrecision=DateToken.PRECISION_SECOND;
    }
    int millisecondValue=0;
    if (millisecond.connectedPortList().size() > 0 && millisecond.hasToken(0)) {
      millisecondValue=((IntToken)millisecond.get(0)).intValue();
      datePrecision=DateToken.PRECISION_MILLISECOND;
    }
    int microsecondValue=0;
    if (microsecond.connectedPortList().size() > 0 && microsecond.hasToken(0)) {
      microsecondValue=((IntToken)microsecond.get(0)).intValue();
      datePrecision=DateToken.PRECISION_MICROSECOND;
    }
    int nanosecondValue=0;
    if (nanosecond.connectedPortList().size() > 0 && nanosecond.hasToken(0)) {
      nanosecondValue=((IntToken)nanosecond.get(0)).intValue();
      datePrecision=DateToken.PRECISION_NANOSECOND;
    }
    String timeZoneValue=TimeZone.getDefault().getID();
    if (timeZone.connectedPortList().size() > 0 && timeZone.hasToken(0)) {
      timeZoneValue=((StringToken)timeZone.get(0)).stringValue();
    }
    dateToken=new DateToken();
    dateToken.getCalendarInstance().setTimeZone(TimeZone.getTimeZone(timeZoneValue));
    dateToken.getCalendarInstance().set(Calendar.YEAR,yearValue);
    dateToken.getCalendarInstance().set(Calendar.MONTH,monthValue);
    dateToken.getCalendarInstance().set(Calendar.DAY_OF_MONTH,dayValue);
    dateToken.getCalendarInstance().set(Calendar.HOUR,hourValue);
    dateToken.getCalendarInstance().set(Calendar.MINUTE,minuteValue);
    dateToken.getCalendarInstance().set(Calendar.SECOND,secondValue);
    dateToken.getCalendarInstance().set(Calendar.MILLISECOND,millisecondValue);
    dateToken.addMicroseconds(microsecondValue);
    dateToken.addNanoseconds(nanosecondValue);
  }
  output.send(0,dateToken);
}

Fixed version (ground truth):
/** 
 * Construct a date token with all tokens present. If a token for the long value is present, use this token and time zone as well as precision. Otherwise use tokens on other inputs to create ports.
 * @exception IllegalActionException If there is no director.
 */
@Override public void fire() throws IllegalActionException {
  super.fire();
  DateToken dateToken=null;
  int datePrecision=DateToken.PRECISION_MILLISECOND;
  if (timeAsLong.connectedPortList().size() > 0 && timeAsLong.hasToken(0)) {
    long timeAsLongValue=1l;
    timeAsLongValue=((LongToken)timeAsLong.get(0)).longValue();
    String precisionValue="String_Node_Str";
    precisionValue=((StringToken)precision.getToken()).stringValue();
    if (precisionValue.equals("String_Node_Str")) {
      datePrecision=DateToken.PRECISION_SECOND;
    }
    if (precisionValue.equals("String_Node_Str")) {
      datePrecision=DateToken.PRECISION_MILLISECOND;
    }
    if (precisionValue.equals("String_Node_Str")) {
      datePrecision=DateToken.PRECISION_MICROSECOND;
    }
    if (precisionValue.equals("String_Node_Str")) {
      datePrecision=DateToken.PRECISION_NANOSECOND;
    }
 else {
      datePrecision=DateToken.PRECISION_MILLISECOND;
    }
    String timeZoneValue=TimeZone.getDefault().getID();
    if ((timeZone.connectedPortList().size() > 0) && timeZone.hasToken(0)) {
      timeZoneValue=((StringToken)timeZone.get(0)).stringValue();
    }
    dateToken=new DateToken(timeAsLongValue,datePrecision,TimeZone.getTimeZone(timeZoneValue));
  }
 else {
    int yearValue=1970;
    if (year.connectedPortList().size() > 0 && year.hasToken(0)) {
      yearValue=((IntToken)year.get(0)).intValue();
    }
    int monthValue=1;
    if (month.connectedPortList().size() > 0 && month.hasToken(0)) {
      monthValue=((IntToken)month.get(0)).intValue();
    }
    int dayValue=1;
    if (day.connectedPortList().size() > 0 && day.hasToken(0)) {
      dayValue=((IntToken)day.get(0)).intValue();
    }
    int hourValue=0;
    if (hour.connectedPortList().size() > 0 && hour.hasToken(0)) {
      hourValue=((IntToken)hour.get(0)).intValue();
    }
    int minuteValue=0;
    if (minute.connectedPortList().size() > 0 && minute.hasToken(0)) {
      minuteValue=((IntToken)minute.get(0)).intValue();
    }
    int secondValue=0;
    if (second.connectedPortList().size() > 0 && second.hasToken(0)) {
      secondValue=((IntToken)second.get(0)).intValue();
      datePrecision=DateToken.PRECISION_SECOND;
    }
    int millisecondValue=0;
    if (millisecond.connectedPortList().size() > 0 && millisecond.hasToken(0)) {
      millisecondValue=((IntToken)millisecond.get(0)).intValue();
      datePrecision=DateToken.PRECISION_MILLISECOND;
    }
    int microsecondValue=0;
    if (microsecond.connectedPortList().size() > 0 && microsecond.hasToken(0)) {
      microsecondValue=((IntToken)microsecond.get(0)).intValue();
      datePrecision=DateToken.PRECISION_MICROSECOND;
    }
    int nanosecondValue=0;
    if (nanosecond.connectedPortList().size() > 0 && nanosecond.hasToken(0)) {
      nanosecondValue=((IntToken)nanosecond.get(0)).intValue();
      datePrecision=DateToken.PRECISION_NANOSECOND;
    }
    String timeZoneValue=TimeZone.getDefault().getID();
    if ((timeZone.connectedPortList().size() > 0) && timeZone.hasToken(0)) {
      timeZoneValue=((StringToken)timeZone.get(0)).stringValue();
    }
    Calendar c=Calendar.getInstance();
    c.set(Calendar.YEAR,yearValue);
    c.set(Calendar.MONTH,monthValue);
    c.set(Calendar.DAY_OF_MONTH,dayValue);
    c.set(Calendar.HOUR,hourValue);
    c.set(Calendar.MINUTE,minuteValue);
    c.set(Calendar.SECOND,secondValue);
    c.set(Calendar.MILLISECOND,millisecondValue);
    c.setTimeZone(TimeZone.getTimeZone(timeZoneValue));
    dateToken=new DateToken(c.getTimeInMillis(),DateToken.PRECISION_MILLISECOND,TimeZone.getTimeZone(timeZoneValue));
    dateToken.addMicroseconds(microsecondValue);
    dateToken.addNanoseconds(nanosecondValue);
  }
  output.send(0,dateToken);
}