Program: 66888
Project: 66888
Buggy source:
/** 
 * Returns the formatted string representation of given object.
 * @param oValue
 * @param fs
 * @param lcl
 * @return formatted string
 */
public static final String format(Object oValue,FormatSpecifier fs,ULocale lcl,Object oCachedJavaFormatter) throws ChartException {
  String sValue;
  if (oValue == null) {
    return null;
  }
 else   if ((oValue instanceof String) && !(fs instanceof StringFormatSpecifier)) {
    return (String)oValue;
  }
  if (fs instanceof DateFormatSpecifier || fs instanceof JavaDateFormatSpecifier) {
    if (!(oValue instanceof Calendar || oValue instanceof DateTimeDataElement)) {
      fs=null;
    }
  }
 else   if (fs instanceof NumberFormatSpecifier || fs instanceof JavaNumberFormatSpecifier || fs instanceof FractionNumberFormatSpecifier) {
    if (!(oValue instanceof Number || oValue instanceof NumberDataElement || oValue instanceof BigNumberDataElement|| NumberUtil.isBigNumber(oValue)|| NumberUtil.isBigDecimal(oValue))) {
      fs=null;
    }
  }
 else   if (fs instanceof StringFormatSpecifier) {
    if (!(oValue instanceof String)) {
      fs=null;
    }
  }
  if (fs == null) {
    if (oCachedJavaFormatter != null) {
      if (NumberUtil.isBigNumber(oValue)) {
        return ((DecimalFormat)oCachedJavaFormatter).format(((BigNumber)oValue).getValue());
      }
 else       if (NumberUtil.isBigDecimal(oValue)) {
        return ((DecimalFormat)oCachedJavaFormatter).format(oValue);
      }
 else       if (oValue instanceof Double || oValue instanceof NumberDataElement) {
        if (oCachedJavaFormatter instanceof DecimalFormat) {
          final double dValue=oValue instanceof Double ? ((Double)oValue).doubleValue() : ((NumberDataElement)oValue).getValue();
          sValue=((DecimalFormat)oCachedJavaFormatter).format(dValue);
          return correctNumber(sValue);
        }
      }
 else       if (oValue instanceof Calendar || oValue instanceof DateTimeDataElement) {
        Calendar calendar=oValue instanceof Calendar ? (Calendar)oValue : ((DateTimeDataElement)oValue).getValueAsCalendar();
        if (oCachedJavaFormatter instanceof IDateFormatWrapper) {
          return ((IDateFormatWrapper)oCachedJavaFormatter).format(calendar.getTime());
        }
 else         if (oCachedJavaFormatter instanceof DateFormat) {
          return ((DateFormat)oCachedJavaFormatter).format(calendar);
        }
 else         if (oCachedJavaFormatter instanceof DateFormatSpecifier) {
          return ((DateFormatSpecifier)oCachedJavaFormatter).format(calendar,lcl);
        }
      }
 else       if (oValue instanceof IDataPointEntry) {
        if (oCachedJavaFormatter instanceof FormatSpecifier) {
          return ((IDataPointEntry)oValue).getFormattedString((FormatSpecifier)oCachedJavaFormatter,lcl);
        }
      }
    }
 else {
      if (NumberUtil.isBigNumber(oValue)) {
        return NumberUtil.getDefaultBigDecimalFormat(lcl).format(((BigNumber)oValue).getValue());
      }
 else       if (NumberUtil.isBigDecimal(oValue)) {
        return NumberUtil.getDefaultBigDecimalFormat(lcl).format(oValue);
      }
 else       if (oValue instanceof Number) {
        return NumberFormat.getInstance(lcl).format(((Number)oValue).doubleValue());
      }
 else       if (oValue instanceof NumberDataElement) {
        return NumberFormat.getInstance(lcl).format(((NumberDataElement)oValue).getValue());
      }
 else       if (oValue instanceof BigNumberDataElement) {
        return NumberFormat.getInstance(lcl).format(((BigNumberDataElement)oValue).getValue());
      }
 else       if (oValue instanceof Calendar) {
        return DateFormat.getDateTimeInstance(DateFormat.SHORT,DateFormat.SHORT,lcl).format(oValue);
      }
 else       if (oValue instanceof DateTimeDataElement) {
        return DateFormat.getDateTimeInstance(DateFormat.SHORT,DateFormat.SHORT,lcl).format(((DateTimeDataElement)oValue).getValueAsCalendar());
      }
 else       if (oValue instanceof IDataPointEntry) {
        return ((IDataPointEntry)oValue).getFormattedString(null,lcl);
      }
    }
  }
 else   if (oValue instanceof IDataPointEntry) {
    return ((IDataPointEntry)oValue).getFormattedString(fs,lcl);
  }
 else   if (NumberFormatSpecifier.class.isInstance(fs)) {
    final NumberFormatSpecifier nfs=(NumberFormatSpecifier)fs;
    if (NumberUtil.isBigNumber(oValue)) {
      return correctNumber(nfs.format(((BigNumber)oValue).getValue(),lcl));
    }
 else     if (NumberUtil.isBigDecimal(oValue)) {
      return correctNumber(nfs.format((BigDecimal)oValue,lcl));
    }
 else {
      final double dValue=asPrimitiveDouble(oValue,lcl);
      return correctNumber(nfs.format(dValue,lcl));
    }
  }
 else   if (JavaNumberFormatSpecifier.class.isInstance(fs)) {
    final JavaNumberFormatSpecifier nfs=(JavaNumberFormatSpecifier)fs;
    if (NumberUtil.isBigNumber(oValue)) {
      return correctNumber(nfs.format(((BigNumber)oValue).getValue(),lcl));
    }
 else     if (NumberUtil.isBigDecimal(oValue)) {
      return correctNumber(nfs.format((BigDecimal)oValue,lcl));
    }
 else {
      final double dValue=asPrimitiveDouble(oValue,lcl);
      return correctNumber(nfs.format(dValue,lcl));
    }
  }
 else   if (FractionNumberFormatSpecifier.class.isInstance(fs)) {
    final FractionNumberFormatSpecifier fnfs=(FractionNumberFormatSpecifier)fs;
    final double dValue=asPrimitiveDouble(oValue,lcl);
    return correctNumber(fnfs.format(dValue,lcl));
  }
 else   if (DateFormatSpecifier.class.isInstance(fs)) {
    final DateFormatSpecifier dfs=(DateFormatSpecifier)fs;
    return dfs.format(asCalendar(oValue,lcl),lcl);
  }
 else   if (JavaDateFormatSpecifier.class.isInstance(fs)) {
    final JavaDateFormatSpecifier jdfs=(JavaDateFormatSpecifier)fs;
    return jdfs.format(asCalendar(oValue,lcl),lcl);
  }
 else   if (StringFormatSpecifier.class.isInstance(fs)) {
    final StringFormatSpecifier jdfs=(StringFormatSpecifier)fs;
    return jdfs.format(oValue.toString(),lcl);
  }
 else {
    if (NumberUtil.isBigNumber(oValue)) {
      return NumberUtil.getDefaultBigDecimalFormat(lcl).format(((BigNumber)oValue).getValue());
    }
 else     if (NumberUtil.isBigDecimal(oValue)) {
      return NumberUtil.getDefaultBigDecimalFormat(lcl).format(oValue);
    }
 else     if (oValue instanceof Number) {
      return NumberFormat.getInstance(lcl).format(((Number)oValue).doubleValue());
    }
 else     if (oValue instanceof NumberDataElement) {
      return NumberFormat.getInstance(lcl).format(((NumberDataElement)oValue).getValue());
    }
 else     if (oValue instanceof Calendar) {
      return DateFormat.getDateTimeInstance(DateFormat.SHORT,DateFormat.SHORT,lcl).format(oValue);
    }
 else     if (oValue instanceof DateTimeDataElement) {
      return DateFormat.getDateTimeInstance(DateFormat.SHORT,DateFormat.SHORT,lcl).format(((DateTimeDataElement)oValue).getValueAsCalendar());
    }
  }
  return oValue.toString();
}

Fixed version (ground truth):
/** 
 * Returns the formatted string representation of given object.
 * @param oValue
 * @param fs
 * @param lcl
 * @return formatted string
 */
public static final String format(Object oValue,FormatSpecifier fs,ULocale lcl,Object oCachedJavaFormatter) throws ChartException {
  String sValue;
  if (oValue == null) {
    return null;
  }
 else   if ((oValue instanceof String) && !(fs instanceof StringFormatSpecifier)) {
    return (String)oValue;
  }
  if (fs instanceof DateFormatSpecifier || fs instanceof JavaDateFormatSpecifier) {
    if (!(oValue instanceof Calendar || oValue instanceof DateTimeDataElement)) {
      fs=null;
    }
  }
 else   if (fs instanceof NumberFormatSpecifier || fs instanceof JavaNumberFormatSpecifier || fs instanceof FractionNumberFormatSpecifier) {
    if (!(oValue instanceof Number || oValue instanceof NumberDataElement || oValue instanceof BigNumberDataElement|| NumberUtil.isBigNumber(oValue)|| NumberUtil.isBigDecimal(oValue))) {
      fs=null;
    }
  }
 else   if (fs instanceof StringFormatSpecifier) {
    if (!(oValue instanceof String)) {
      fs=null;
    }
  }
  if (fs == null) {
    if (oCachedJavaFormatter != null) {
      if (NumberUtil.isBigNumber(oValue)) {
        return ((DecimalFormat)oCachedJavaFormatter).format(((BigNumber)oValue).getValue());
      }
 else       if (NumberUtil.isBigDecimal(oValue)) {
        return ((DecimalFormat)oCachedJavaFormatter).format(oValue);
      }
 else       if (oValue instanceof Double || oValue instanceof NumberDataElement) {
        if (oCachedJavaFormatter instanceof DecimalFormat) {
          final double dValue=oValue instanceof Double ? ((Double)oValue).doubleValue() : ((NumberDataElement)oValue).getValue();
          sValue=((DecimalFormat)oCachedJavaFormatter).format(dValue);
          return correctNumber(sValue);
        }
      }
 else       if (oValue instanceof Calendar || oValue instanceof DateTimeDataElement) {
        Calendar calendar=oValue instanceof Calendar ? (Calendar)oValue : ((DateTimeDataElement)oValue).getValueAsCalendar();
        if (oCachedJavaFormatter instanceof IDateFormatWrapper) {
          return ((IDateFormatWrapper)oCachedJavaFormatter).format(calendar.getTime());
        }
 else         if (oCachedJavaFormatter instanceof DateFormat) {
          return ((DateFormat)oCachedJavaFormatter).format(calendar);
        }
 else         if (oCachedJavaFormatter instanceof DateFormatSpecifier) {
          return ((DateFormatSpecifier)oCachedJavaFormatter).format(calendar,lcl);
        }
      }
 else       if (oValue instanceof IDataPointEntry) {
        if (oCachedJavaFormatter instanceof FormatSpecifier) {
          return ((IDataPointEntry)oValue).getFormattedString((FormatSpecifier)oCachedJavaFormatter,lcl);
        }
      }
    }
 else {
      if (NumberUtil.isBigNumber(oValue)) {
        return NumberUtil.getDefaultBigDecimalFormat(lcl).format(((BigNumber)oValue).getValue());
      }
 else       if (NumberUtil.isBigDecimal(oValue)) {
        return NumberUtil.getDefaultBigDecimalFormat(lcl).format(oValue);
      }
 else       if (oValue instanceof Number) {
        return NumberFormat.getInstance(lcl).format(((Number)oValue).doubleValue());
      }
 else       if (oValue instanceof NumberDataElement) {
        return NumberFormat.getInstance(lcl).format(((NumberDataElement)oValue).getValue());
      }
 else       if (oValue instanceof BigNumberDataElement) {
        return NumberFormat.getInstance(lcl).format(((BigNumberDataElement)oValue).getValue());
      }
 else       if (oValue instanceof Calendar) {
        return DateFormat.getDateTimeInstance(DateFormat.SHORT,DateFormat.SHORT,lcl).format(oValue);
      }
 else       if (oValue instanceof DateTimeDataElement) {
        return DateFormat.getDateTimeInstance(DateFormat.SHORT,DateFormat.SHORT,lcl).format(((DateTimeDataElement)oValue).getValueAsCalendar());
      }
 else       if (oValue instanceof IDataPointEntry) {
        return ((IDataPointEntry)oValue).getFormattedString(null,lcl);
      }
    }
  }
 else   if (oValue instanceof IDataPointEntry) {
    return ((IDataPointEntry)oValue).getFormattedString(fs,lcl);
  }
 else   if (NumberFormatSpecifier.class.isInstance(fs)) {
    final NumberFormatSpecifier nfs=(NumberFormatSpecifier)fs;
    if (NumberUtil.isBigNumber(oValue)) {
      return correctNumber(nfs.format(((BigNumber)oValue).getValue(),lcl));
    }
 else     if (NumberUtil.isBigDecimal(oValue)) {
      return correctNumber(nfs.format((Number)oValue,lcl));
    }
 else {
      final double dValue=asPrimitiveDouble(oValue,lcl);
      return correctNumber(nfs.format(dValue,lcl));
    }
  }
 else   if (JavaNumberFormatSpecifier.class.isInstance(fs)) {
    final JavaNumberFormatSpecifier nfs=(JavaNumberFormatSpecifier)fs;
    if (NumberUtil.isBigNumber(oValue)) {
      return correctNumber(nfs.format(((BigNumber)oValue).getValue(),lcl));
    }
 else     if (NumberUtil.isBigDecimal(oValue)) {
      return correctNumber(nfs.format((Number)oValue,lcl));
    }
 else {
      final double dValue=asPrimitiveDouble(oValue,lcl);
      return correctNumber(nfs.format(dValue,lcl));
    }
  }
 else   if (FractionNumberFormatSpecifier.class.isInstance(fs)) {
    final FractionNumberFormatSpecifier fnfs=(FractionNumberFormatSpecifier)fs;
    final double dValue=asPrimitiveDouble(oValue,lcl);
    return correctNumber(fnfs.format(dValue,lcl));
  }
 else   if (DateFormatSpecifier.class.isInstance(fs)) {
    final DateFormatSpecifier dfs=(DateFormatSpecifier)fs;
    return dfs.format(asCalendar(oValue,lcl),lcl);
  }
 else   if (JavaDateFormatSpecifier.class.isInstance(fs)) {
    final JavaDateFormatSpecifier jdfs=(JavaDateFormatSpecifier)fs;
    return jdfs.format(asCalendar(oValue,lcl),lcl);
  }
 else   if (StringFormatSpecifier.class.isInstance(fs)) {
    final StringFormatSpecifier jdfs=(StringFormatSpecifier)fs;
    return jdfs.format(oValue.toString(),lcl);
  }
 else {
    if (NumberUtil.isBigNumber(oValue)) {
      return NumberUtil.getDefaultBigDecimalFormat(lcl).format(((BigNumber)oValue).getValue());
    }
 else     if (NumberUtil.isBigDecimal(oValue)) {
      return NumberUtil.getDefaultBigDecimalFormat(lcl).format(oValue);
    }
 else     if (oValue instanceof Number) {
      return NumberFormat.getInstance(lcl).format(((Number)oValue).doubleValue());
    }
 else     if (oValue instanceof NumberDataElement) {
      return NumberFormat.getInstance(lcl).format(((NumberDataElement)oValue).getValue());
    }
 else     if (oValue instanceof Calendar) {
      return DateFormat.getDateTimeInstance(DateFormat.SHORT,DateFormat.SHORT,lcl).format(oValue);
    }
 else     if (oValue instanceof DateTimeDataElement) {
      return DateFormat.getDateTimeInstance(DateFormat.SHORT,DateFormat.SHORT,lcl).format(((DateTimeDataElement)oValue).getValueAsCalendar());
    }
  }
  return oValue.toString();
}