use of javax.money.format.AmountFormatQuery in project jsr354-ri by JavaMoney.
the class MonetaryFormatsTest method testParse_CNY_zh_CN.
@Test
public void testParse_CNY_zh_CN() {
AmountFormatQuery formatQuery = AmountFormatQueryBuilder.of(CHINA).set(CODE).build();
MonetaryAmountFormat format = MonetaryFormats.getAmountFormat(formatQuery);
assertMoneyParse(format, "CNY00000123", 123.0, "CNY");
assertMoneyParse(format, "CNY123.01", 123.01, "CNY");
assertMoneyParse(format, "CNY14,000.12", 14000.12, "CNY");
assertMoneyParse(format, "CNY 14,000.12", 14000.12, "CNY");
assertMoneyParse(format, "CNY\u00A014,000.12", 14000.12, "CNY");
}
use of javax.money.format.AmountFormatQuery in project jsr354-ri by JavaMoney.
the class MonetaryFormatsTest method testFormat_CNY_zh_CN.
@Test
public void testFormat_CNY_zh_CN() {
AmountFormatQuery formatQuery = AmountFormatQueryBuilder.of(CHINA).set(CODE).build();
MonetaryAmountFormat format = MonetaryFormats.getAmountFormat(formatQuery);
assertMoneyFormat(format, Money.of(123.01, "CNY"), "CNY123.01");
assertMoneyFormat(format, Money.of(14000.12, "CNY"), "CNY14,000.12");
}
use of javax.money.format.AmountFormatQuery in project jsr354-ri by JavaMoney.
the class MonetaryAmountFormatTest method testFormatWithBuilder.
/**
* Test method for
* {@link javax.money.format.MonetaryAmountFormat#format(javax.money.MonetaryAmount)} .
*/
@Test
public void testFormatWithBuilder() {
AmountFormatQuery formatQuery = AmountFormatQueryBuilder.of(JAPANESE).build();
MonetaryAmountFormat defaultFormat = MonetaryFormats.getAmountFormat(formatQuery);
MonetaryAmount amountChf = Monetary.getDefaultAmountFactory().setCurrency("CHF").setNumber(12.50).create();
assertEquals("CHF12.50", defaultFormat.format(amountChf));
}
use of javax.money.format.AmountFormatQuery in project bookJava11eDeitel by diodoros87.
the class SimpleCurrencyConverterView method getMonetaryAmountFormat.
private static MonetaryAmountFormat getMonetaryAmountFormat() {
AmountFormatQueryBuilder builder = AmountFormatQueryBuilder.of(LOCALE_FORMAT);
builder.set(SYMBOL);
builder.set(PATTERN, " ยค,##0.00");
AmountFormatQuery query = builder.build();
MonetaryAmountFormat monetaryAmountFormat = MonetaryFormats.getAmountFormat(query);
return monetaryAmountFormat;
}
Aggregations