当前位置: 首页>>代码示例>>Java>>正文


Java MonetaryConversions.getConversion方法代码示例

本文整理汇总了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()))));
}
 
开发者ID:JavaMoney,项目名称:javamoney-examples,代码行数:22,代码来源:ConversionExample.java

示例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()))));
}
 
开发者ID:JavaMoney,项目名称:javamoney-examples,代码行数:21,代码来源:ConversionExample.java

示例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);
}
 
开发者ID:JavaMoney,项目名称:jsr354-ri,代码行数:8,代码来源:MonetaryConversionTest.java

示例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);
}
 
开发者ID:JavaMoney,项目名称:jsr354-ri,代码行数:8,代码来源:MonetaryConversionTest.java


注:本文中的javax.money.convert.MonetaryConversions.getConversion方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。