code: public String format(MonetaryAmount amount){
          StringBuilder b = new StringBuilder();
          try{
              print(b, amount);
          }
          catch(IOException e){
              throw new IllegalStateException("Formatting error.", e);
          }
          return b.toString();
      }
docs: Formats the given {@link javax.money.MonetaryAmount} to a String.
  
  @param amount the amount to format, not {@code null}
  @return the string printed using the settings of this formatter
  @throws UnsupportedOperationException if the formatter is unable to print