Program: 91926
Project: 91926
Buggy source:
/** 
 * Format the timestamp according to its pattern.
 * @param value the timestamp value to format (in ns)
 * @return the formatted timestamp
 */
public synchronized String format(long value){
  long date=value / 1000000;
  long sec=value / 1000000000;
  long ms=Math.abs(value) % 1000000000 / 1000000;
  long cs=Math.abs(value) % 1000000 / 1000;
  long ns=Math.abs(value) % 1000;
  if (value < 0 && ms + cs + ns > 0 && !fPattern.contains("String_Node_Str")) {
    date-=1;
    long nanosec=1000000000 - (1000000 * ms + 1000 * cs + ns);
    ms=nanosec / 1000000;
    cs=nanosec % 1000000 / 1000;
    ns=nanosec % 1000;
  }
  StringBuffer result=new StringBuffer(super.format(date));
  int loc=result.indexOf(fCloseBracket + "String_Node_Str" + fOpenBracket);
  while (loc != -1) {
    result.deleteCharAt(loc + fCloseBracket.length());
    loc=result.indexOf(fCloseBracket + "String_Node_Str" + fOpenBracket);
  }
  for (  String pattern : fSupplPatterns) {
    int length=pattern.length();
    StringBuffer fmt=new StringBuffer(length);
    for (int i=0; i < length; i++) {
      fmt.append("String_Node_Str");
    }
    DecimalFormat dfmt=new DecimalFormat(fmt.toString());
    String fmtVal="String_Node_Str";
switch (pattern.charAt(0)) {
case 'T':
      if (value < 0 && sec == 0) {
        result.insert(0,'-');
      }
    fmtVal=dfmt.format(sec);
  break;
case 'S':
fmtVal=dfmt.format(ms);
break;
case 'C':
fmtVal=dfmt.format(cs);
break;
case 'N':
fmtVal=dfmt.format(ns);
break;
default :
break;
}
String ph=new StringBuffer(fOpenBracket + pattern + fCloseBracket).toString();
loc=result.indexOf(ph);
result.replace(loc,loc + length + fOpenBracket.length()+ fCloseBracket.length(),fmtVal);
}
return result.toString();
}

Fixed version (ground truth):
/** 
 * Format the timestamp according to its pattern.
 * @param value the timestamp value to format (in ns)
 * @return the formatted timestamp
 */
public synchronized String format(long value){
  long date=value / 1000000;
  long sec=value / 1000000000;
  long ms=Math.abs((value % 1000000000) / 1000000);
  long cs=Math.abs((value % 1000000) / 1000);
  long ns=Math.abs(value % 1000);
  if (value < 0 && ms + cs + ns > 0 && !super.toPattern().contains(fOpenBracket + "String_Node_Str")) {
    date-=1;
    long nanosec=1000000000 - (1000000 * ms + 1000 * cs + ns);
    ms=nanosec / 1000000;
    cs=(nanosec % 1000000) / 1000;
    ns=nanosec % 1000;
  }
  StringBuffer result=new StringBuffer(super.format(date));
  result.append(fSubSecPattern);
  for (  String pattern : fSupplPatterns) {
    int length=pattern.length();
    StringBuffer fmt=new StringBuffer(length);
    for (int i=0; i < length; i++) {
      fmt.append("String_Node_Str");
    }
    DecimalFormat dfmt=new DecimalFormat(fmt.toString());
    String fmtVal="String_Node_Str";
switch (pattern.charAt(0)) {
case 'T':
      if (value < 0 && sec == 0) {
        result.insert(0,'-');
      }
    fmtVal=dfmt.format(sec);
  break;
case 'S':
fmtVal=dfmt.format(ms);
break;
case 'C':
fmtVal=dfmt.format(cs);
break;
case 'N':
fmtVal=dfmt.format(ns);
break;
default :
break;
}
String ph=new StringBuffer(fOpenBracket + pattern + fCloseBracket).toString();
int loc=result.indexOf(ph);
result.replace(loc,loc + length + fOpenBracket.length()+ fCloseBracket.length(),fmtVal);
}
return result.toString();
}