?????????????ExchangeRateProvider??????????CompoundRateProvider??CompoundRateProvider????????????????????ExchangeRateProvider???????????????????????????????????
????// get the exchange rate from euro to us dollar
????ExchangeRate rate = exchangeRateProvider.getExchangeRate("EUR"?? "USD");
????NumberValue factor = rate.getFactor(); // 1.2537 (at time writing)
????CurrencyUnit baseCurrency = rate.getBaseCurrency(); // EUR
????CurrencyUnit targetCurrency = rate.getCurrency(); // USD
???????????
???????????????????????ExchangeRateProvider?????CurrencyConversions????ɡ?
????// get the CurrencyConversion from the default provider chain
????CurrencyConversion dollarConversion = MonetaryConversions.getConversion("USD");
????// get the CurrencyConversion from a specific provider
????CurrencyConversion ecbDollarConversion = ecbExchangeRateProvider.getCurrencyConversion("USD");
????MonetaryAmount tenEuro = Money.of(10?? "EUR");
????// convert 10 euro to us dollar
????MonetaryAmount inDollar = tenEuro.with(dollarConversion); // "USD 12.537" (at the time writing)
?????????CurrencyConversion??????MonetaryOperator?????????????????????????????MonetaryAmount.with()?????????á?
???????????????
????MonetaryAmount???????MonetaryAmountFormat????????????н???/???????
????// formatting by locale specific formats
????MonetaryAmountFormat germanFormat = MonetaryFormats.getAmountFormat(Locale.GERMANY);
????MonetaryAmountFormat usFormat = MonetaryFormats.getAmountFormat(Locale.CANADA);
????MonetaryAmount amount = Money.of(12345.67?? "USD");
????String usFormatted = usFormat.format(amount); // "USD12??345.67"
????String germanFormatted = germanFormat.format(amount); // 12.345??67 USD
????// A MonetaryAmountFormat can also be used to parse MonetaryAmounts from strings
????MonetaryAmount parsed = germanFormat.parse("12??4 USD");
???????????AmountFormatQueryBuilder????????????????
????// Creating a custom MonetaryAmountFormat
????MonetaryAmountFormat customFormat = MonetaryFormats.getAmountFormat(
????AmountFormatQueryBuilder.of(Locale.US)
????.set(CurrencyStyle.NAME)
????.set("pattern"?? "00??00??00??00.00 ¤")
????.build());
????// results in "00??01??23??45.67 US Dollar"
????String formatted = customFormat.format(amount);
????????????¤???????????????????????λ????
???????
?????μ????API???????????ò???????????????????????????????????????????Щ??????????????Java 9?п????????μ???!