Program: 63659
Project: 63659
Buggy source:
private String stringFromSQLTime(Time sourceTime,QName schemaType){
  if (Constants.DATE_TIME_QNAME.equals(schemaType)) {
    XMLGregorianCalendar xgc=getDatatypeFactory().newXMLGregorianCalendar();
    GregorianCalendar cal=new GregorianCalendar(getTimeZone());
    cal.setGregorianChange(new Date(Long.MIN_VALUE));
    cal.setTime(sourceTime);
    if (cal.get(Calendar.ERA) == GregorianCalendar.BC) {
      xgc.setYear(-cal.get(Calendar.YEAR));
    }
 else {
      xgc.setYear(cal.get(Calendar.YEAR));
    }
    xgc.setMonth(cal.get(Calendar.MONTH) + 1);
    xgc.setDay(cal.get(Calendar.DAY_OF_MONTH));
    xgc.setHour(cal.get(Calendar.HOUR_OF_DAY));
    xgc.setMinute(cal.get(Calendar.MINUTE));
    xgc.setSecond(cal.get(Calendar.SECOND));
    String string=xgc.toXMLFormat();
    return appendTimeZone(string,sourceTime);
  }
 else   if (Constants.DATE_QNAME.equals(schemaType)) {
    XMLGregorianCalendar xgc=getDatatypeFactory().newXMLGregorianCalendar();
    GregorianCalendar cal=new GregorianCalendar(getTimeZone());
    cal.setGregorianChange(new Date(Long.MIN_VALUE));
    cal.setTime(sourceTime);
    if (cal.get(Calendar.ERA) == GregorianCalendar.BC) {
      xgc.setYear(-cal.get(Calendar.YEAR));
    }
 else {
      xgc.setYear(cal.get(Calendar.YEAR));
    }
    xgc.setMonth(cal.get(Calendar.MONTH) + 1);
    xgc.setDay(cal.get(Calendar.DAY_OF_MONTH));
    return xgc.toXMLFormat();
  }
 else   if (Constants.G_DAY_QNAME.equals(schemaType)) {
    XMLGregorianCalendar xgc=getDatatypeFactory().newXMLGregorianCalendar();
    GregorianCalendar cal=new GregorianCalendar(getTimeZone());
    cal.setGregorianChange(new Date(Long.MIN_VALUE));
    cal.setTime(sourceTime);
    xgc.setDay(cal.get(Calendar.DAY_OF_MONTH));
    return xgc.toXMLFormat();
  }
 else   if (Constants.G_MONTH_QNAME.equals(schemaType)) {
    XMLGregorianCalendar xgc=getDatatypeFactory().newXMLGregorianCalendar();
    GregorianCalendar cal=new GregorianCalendar(getTimeZone());
    cal.setGregorianChange(new Date(Long.MIN_VALUE));
    cal.setTime(sourceTime);
    xgc.setMonth(cal.get(Calendar.MONTH) + 1);
    return stringFromXMLGregorianCalendar(xgc,schemaType);
  }
 else   if (Constants.G_MONTH_DAY_QNAME.equals(schemaType)) {
    XMLGregorianCalendar xgc=getDatatypeFactory().newXMLGregorianCalendar();
    GregorianCalendar cal=new GregorianCalendar(getTimeZone());
    cal.setGregorianChange(new Date(Long.MIN_VALUE));
    cal.setTime(sourceTime);
    xgc.setMonth(cal.get(Calendar.MONTH) + 1);
    xgc.setDay(cal.get(Calendar.DAY_OF_MONTH));
    return xgc.toXMLFormat();
  }
 else   if (Constants.G_YEAR_QNAME.equals(schemaType)) {
    XMLGregorianCalendar xgc=getDatatypeFactory().newXMLGregorianCalendar();
    GregorianCalendar cal=new GregorianCalendar(getTimeZone());
    cal.setGregorianChange(new Date(Long.MIN_VALUE));
    cal.setTime(sourceTime);
    if (cal.get(Calendar.ERA) == GregorianCalendar.BC) {
      xgc.setYear(-cal.get(Calendar.YEAR));
    }
 else {
      xgc.setYear(cal.get(Calendar.YEAR));
    }
    return xgc.toXMLFormat();
  }
 else   if (Constants.G_YEAR_MONTH_QNAME.equals(schemaType)) {
    XMLGregorianCalendar xgc=getDatatypeFactory().newXMLGregorianCalendar();
    GregorianCalendar cal=new GregorianCalendar(getTimeZone());
    cal.setGregorianChange(new Date(Long.MIN_VALUE));
    cal.setTime(sourceTime);
    if (cal.get(Calendar.ERA) == GregorianCalendar.BC) {
      xgc.setYear(-cal.get(Calendar.YEAR));
    }
 else {
      xgc.setYear(cal.get(Calendar.YEAR));
    }
    xgc.setMonth(cal.get(Calendar.MONTH) + 1);
    return xgc.toXMLFormat();
  }
 else   if (Constants.DURATION_QNAME.equals(schemaType)) {
    throw new IllegalArgumentException();
  }
 else {
    return stringFromSQLTime(sourceTime);
  }
}

Fixed version (ground truth):
private String stringFromSQLTime(Time sourceTime,QName schemaType){
  if (null == schemaType) {
    return stringFromSQLTime(sourceTime);
  }
 else {
    return stringFromDate(sourceTime,schemaType);
  }
}