@Test public void testFormat_with_two_patterns_without_currency() { AmountFormatContextBuilder builder = AmountFormatContextBuilder.of(US); builder.set("pattern", "0.00;0.0"); AmountFormatContext context = builder.build(); DefaultMonetaryAmountFormat format = new DefaultMonetaryAmountFormat(context); String formatted = format.format(FastMoney.of(1000.42, "USD")); assertEquals(formatted, "1000.42"); formatted = format.format(FastMoney.of(-1000.42, "USD")); assertEquals(formatted, "-1000.4"); }
@Override public String format(MonetaryAmount amount) { StringBuilder builder = new StringBuilder(); try { print(builder, amount); } catch (IOException e) { throw new IllegalStateException("Error formatting of " + amount, e); } return builder.toString(); }
DefaultMonetaryAmountFormat implements MonetaryAmountFormat { @Override public String format(MonetaryAmount amount) { StringBuilder builder = new StringBuilder(); try { print(builder, amount); } catch (IOException e) { throw new IllegalStateException("Error formatting of " + amount, e); } return builder.toString(); } }
DefaultMonetaryAmountFormat implements MonetaryAmountFormat { @Override public String format(MonetaryAmount amount) { StringBuilder builder = new StringBuilder(); try { print(builder, amount); } catch (IOException e) { throw new IllegalStateException("Error formatting of " + amount, e); } return builder.toString(); } DefaultMonetaryAmountFormat(AmountFormatContext amountFormatContext); }
DefaultMonetaryAmountFormat implements MonetaryAmountFormat { @Override public String format(MonetaryAmount amount) { StringBuilder builder = new StringBuilder(); try { print(builder, amount); } catch (IOException e) { throw new IllegalStateException("Error formatting of " + amount, e); } return builder.toString(); } DefaultMonetaryAmountFormat(AmountFormatContext amountFormatContext); @Override String format(MonetaryAmount amount); @Override void print(Appendable appendable, MonetaryAmount amount); @Override MonetaryAmount parse(CharSequence text); @Override String queryFrom(MonetaryAmount amount); @Override AmountFormatContext getContext(); }
DefaultMonetaryAmountFormat implements MonetaryAmountFormat { @Override public String format(MonetaryAmount amount) { StringBuilder builder = new StringBuilder(); try { print(builder, amount); } catch (IOException e) { throw new IllegalStateException("Error formatting of " + amount, e); } return builder.toString(); } DefaultMonetaryAmountFormat(AmountFormatContext amountFormatContext); @Override String format(MonetaryAmount amount); @Override void print(Appendable appendable, MonetaryAmount amount); @Override MonetaryAmount parse(CharSequence text); @Override String queryFrom(MonetaryAmount amount); @Override AmountFormatContext getContext();  }