本文整理汇总了Java中javax.money.convert.MonetaryConversions.getConversion方法的典型用法代码示例。如果您正苦于以下问题:Java MonetaryConversions.getConversion方法的具体用法?Java MonetaryConversions.getConversion怎么用?Java MonetaryConversions.getConversion使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.money.convert.MonetaryConversions
的用法示例。
在下文中一共展示了MonetaryConversions.getConversion方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: main
import javax.money.convert.MonetaryConversions; //导入方法依赖的package包/类
public static void main(String... args) {
String termCurrencyCode = DEFAULT_TERM_CURRENCY_CODE;
if (args.length > 0) {
termCurrencyCode = args[0];
}
final MonetaryAmount amt = Money.of(2000, "EUR");
CurrencyConversion conv= MonetaryConversions.getConversion(termCurrencyCode, "ECB");
System.out.println(MessageFormat.format("2000 EUR (ECB)-> {0} = {1}",
termCurrencyCode, amt.with(conv)));
conv= MonetaryConversions.getConversion(termCurrencyCode, "IMF");
System.out.println(MessageFormat.format("2000 EUR (IMF)-> {0} = {1}",
termCurrencyCode, amt.with(conv)));
System.out.println(MessageFormat.format(
"2000 EUR (ECB, at 5th Jan 2015)-> {0} = {1}",
termCurrencyCode, amt.with(MonetaryConversions
.getConversion(ConversionQueryBuilder.of()
.setTermCurrency(termCurrencyCode)
//.set(LocalDate.of(2015, 01, 05))
.build()))));
}
示例2: main
import javax.money.convert.MonetaryConversions; //导入方法依赖的package包/类
public static void main(String... args) {
String termCurrencyCode = DEFAULT_TERM_CURRENCY_CODE;
if (args.length > 0) {
termCurrencyCode = args[0];
}
final MonetaryAmount amt = Money.of(2000, "EUR");
CurrencyConversion conv= MonetaryConversions.getConversion(termCurrencyCode, "ECB");
System.out.println(MessageFormat.format("2000 EUR (ECB)-> {0} = {1}",
termCurrencyCode, amt.with(conv)));
conv= MonetaryConversions.getConversion(termCurrencyCode, "IMF");
System.out.println(MessageFormat.format("2000 EUR (IMF)-> {0} = {1}",
termCurrencyCode, amt.with(conv)));
System.out.println(MessageFormat.format(
"2000 EUR (ECB, at 5th Jan 2015)-> {0} = {1}",
termCurrencyCode, amt.with(MonetaryConversions
.getConversion(ConversionQueryBuilder.of()
.setTermCurrency(termCurrencyCode)
.set(LocalDate.of(2015, 01, 05)).build()))));
}
示例3: testMonetaryConversionsECB
import javax.money.convert.MonetaryConversions; //导入方法依赖的package包/类
@Test
public void testMonetaryConversionsECB() {
final MonetaryAmount amt = Money.of(2000, "EUR");
CurrencyConversion conv= MonetaryConversions.getConversion("CHF", "ECB");
MonetaryAmount converted = amt.with(conv);
assertNotNull(converted);
}
示例4: testMonetaryConversionsIMF
import javax.money.convert.MonetaryConversions; //导入方法依赖的package包/类
@Test
public void testMonetaryConversionsIMF() {
final MonetaryAmount amt = Money.of(2000, "EUR");
CurrencyConversion conv= MonetaryConversions.getConversion("CHF", "IMF");
MonetaryAmount converted = amt.with(conv);
assertNotNull(converted);
}