code: public String format(MonetaryAmount amount) {
          StringBuilder builder = new StringBuilder();
          try {
              print(builder, amount);
          } catch (IOException e) {
              throw new IllegalStateException("Error foratting of " + amount, e);
          }
          return builder.toString();
      }
docs: Formats a value of {@code T} to a {@code String}. {@link java.util.Locale}
  passed defines the overall target {@link Locale}. This locale state, how the
  {@link MonetaryAmountFormat} should generally behave. The
  {@link java.util.Locale} allows to configure the formatting and parsing
  in arbitrary details. The attributes that are supported are determined by
  the according {@link MonetaryAmountFormat} implementation:
  
  @param amount the amount to print, not {@code null}
  @return the string printed using the settings of this formatter
  @throws UnsupportedOperationException if the formatter is unable to print