code: public StringBuffer format(Object obj, StringBuffer toAppendTo, FieldPosition pos) {
          if (!(obj instanceof CurrencyAmount)) {
              throw new IllegalArgumentException("Invalid type: " + obj.getClass().getName());
          }
          CurrencyAmount currency = (CurrencyAmount) obj;
              
          fmt.setCurrency(currency.getCurrency());
          return fmt.format(currency.getNumber(), toAppendTo, pos);
      }
docs: Override Format.format().
  @see java.text.Format#format(java.lang.Object, java.lang.StringBuffer, java.text.FieldPosition)