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


Java CurrencyConversion.apply方法代码示例

本文整理汇总了Java中javax.money.convert.CurrencyConversion.apply方法的典型用法代码示例。如果您正苦于以下问题:Java CurrencyConversion.apply方法的具体用法?Java CurrencyConversion.apply怎么用?Java CurrencyConversion.apply使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.money.convert.CurrencyConversion的用法示例。


在下文中一共展示了CurrencyConversion.apply方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: shouldHaveExchangeRates

import javax.money.convert.CurrencyConversion; //导入方法依赖的package包/类
@Test
public void shouldHaveExchangeRates() {
    CurrencyConversion currencyConversion = provider.getCurrencyConversion(DOLLAR);
    assertNotNull(currencyConversion);
    int count = 0;
    for (Currency currency : Currency.getAvailableCurrencies()) {
        MonetaryAmount money = Money.of(BigDecimal.ONE, currency.getCurrencyCode());
        try {
            MonetaryAmount result = currencyConversion.apply(money);
            assertTrue(result.getNumber().doubleValue() > 0);
            count++;
        } catch(Exception e) {
            //not a supported currency
        }
    }
    assertTrue(count >=24);
}
 
开发者ID:JavaMoney,项目名称:javamoney-lib,代码行数:18,代码来源:USFederalReserveRateProviderTest.java

示例2: shouldSetTimeInLocalDateTime

import javax.money.convert.CurrencyConversion; //导入方法依赖的package包/类
@Test(expectedExceptions = MonetaryException.class)
public void shouldSetTimeInLocalDateTime() {

	LocalDate localDate = YearMonth.of(2014, Month.JANUARY).atDay(9);

	ConversionQuery conversionQuery = ConversionQueryBuilder.of()
			.setTermCurrency(EURO).set(localDate).build();
	CurrencyConversion currencyConversion = provider
			.getCurrencyConversion(conversionQuery);
	assertNotNull(currencyConversion);
	MonetaryAmount money = Money.of(BigDecimal.TEN, DOLLAR);
	MonetaryAmount result = currencyConversion.apply(money);

	assertEquals(result.getCurrency(), EURO);
	assertTrue(result.getNumber().doubleValue() > 0);
}
 
开发者ID:JavaMoney,项目名称:jsr354-ri,代码行数:17,代码来源:ECBHistoric90RateProviderTest.java

示例3: shouldReturnErrorWhenFindFromHistoricalUsingPeriod

import javax.money.convert.CurrencyConversion; //导入方法依赖的package包/类
@Test(expectedExceptions = MonetaryException.class)
public void shouldReturnErrorWhenFindFromHistoricalUsingPeriod() {

	LocalDate localDate = YearMonth.of(2011, Month.JANUARY).atDay(9);

	ConversionQuery conversionQuery = ConversionQueryBuilder.of()
			.setTermCurrency(EURO)
			.set(withDaysBetween(localDate.minusDays(1), localDate))
			.build();
	CurrencyConversion currencyConversion = provider
			.getCurrencyConversion(conversionQuery);
	assertNotNull(currencyConversion);
	MonetaryAmount money = Money.of(BigDecimal.TEN, DOLLAR);
	currencyConversion.apply(money);
	fail();

}
 
开发者ID:JavaMoney,项目名称:jsr354-ri,代码行数:18,代码来源:ECBHistoric90RateProviderTest.java

示例4: main

import javax.money.convert.CurrencyConversion; //导入方法依赖的package包/类
public static void main(String[] args) {
    CurrencyUnit dollar = Monetary.getCurrency("USD");
    CurrencyUnit real = Monetary.getCurrency("BRL");
    MonetaryAmount money = FastMoney.of(10, dollar);
    MonetaryAmount money2 = FastMoney.of(10, real);
    ExchangeRateProvider provider = MonetaryConversions.getExchangeRateProvider(ExchangeRateType.ECB);
    CurrencyConversion currencyConversion = provider.getCurrencyConversion(dollar);
    MonetaryAmount result = currencyConversion.apply(money2);
    MonetaryAmount monetaryAmount = money.add(result);
}
 
开发者ID:otaviojava,项目名称:money-api-book-samples,代码行数:11,代码来源:ExchangeRateProviderExample.java

示例5: shouldConvertsEuroToDollar

import javax.money.convert.CurrencyConversion; //导入方法依赖的package包/类
@Test
public void shouldConvertsEuroToDollar() {
    CurrencyConversion currencyConversion = provider
            .getCurrencyConversion(DOLLAR);
    assertNotNull(currencyConversion);
    MonetaryAmount money = Money.of(BigDecimal.TEN, EURO);
    MonetaryAmount result = currencyConversion.apply(money);

    assertEquals(result.getCurrency(), DOLLAR);
    assertTrue(result.getNumber().doubleValue() > 0);

}
 
开发者ID:JavaMoney,项目名称:jsr354-ri-bp,代码行数:13,代码来源:ECBCurrentRateProviderTest.java

示例6: shouldReturnsSameDollarValue

import javax.money.convert.CurrencyConversion; //导入方法依赖的package包/类
@Test
public void shouldReturnsSameDollarValue() {
    CurrencyConversion currencyConversion = provider.getCurrencyConversion(DOLLAR);
    assertNotNull(currencyConversion);
    MonetaryAmount money = Money.of(BigDecimal.TEN, DOLLAR);
    MonetaryAmount result = currencyConversion.apply(money);

    assertEquals(result.getCurrency(), DOLLAR);
    assertEquals(result.getNumber().numberValue(BigDecimal.class),
            BigDecimal.TEN);

}
 
开发者ID:JavaMoney,项目名称:jsr354-ri-bp,代码行数:13,代码来源:ECBHistoric90RateProviderTest.java

示例7: shouldReturnsSameBrazilianValue

import javax.money.convert.CurrencyConversion; //导入方法依赖的package包/类
@Test
public void shouldReturnsSameBrazilianValue() {
    CurrencyConversion currencyConversion = provider
            .getCurrencyConversion(BRAZILIAN_REAL);
    assertNotNull(currencyConversion);
    MonetaryAmount money = Money.of(BigDecimal.TEN, BRAZILIAN_REAL);
    MonetaryAmount result = currencyConversion.apply(money);

    assertEquals(result.getCurrency(), BRAZILIAN_REAL);
    assertEquals(result.getNumber().numberValue(BigDecimal.class),
            BigDecimal.TEN);

}
 
开发者ID:JavaMoney,项目名称:jsr354-ri-bp,代码行数:14,代码来源:ECBHistoric90RateProviderTest.java

示例8: shouldReturnsSameEuroValue

import javax.money.convert.CurrencyConversion; //导入方法依赖的package包/类
@Test
public void shouldReturnsSameEuroValue() {
    CurrencyConversion currencyConversion = provider
            .getCurrencyConversion(EURO);
    assertNotNull(currencyConversion);
    MonetaryAmount money = Money.of(BigDecimal.TEN, EURO);
    MonetaryAmount result = currencyConversion.apply(money);

    assertEquals(result.getCurrency(), EURO);
    assertEquals(result.getNumber().numberValue(BigDecimal.class),
            BigDecimal.TEN);

}
 
开发者ID:JavaMoney,项目名称:jsr354-ri-bp,代码行数:14,代码来源:ECBHistoricRateProviderTest.java

示例9: shouldConvertsDolarToEuro

import javax.money.convert.CurrencyConversion; //导入方法依赖的package包/类
@Test
public void shouldConvertsDolarToEuro() {
    CurrencyConversion currencyConversion = provider
            .getCurrencyConversion(EURO);
    assertNotNull(currencyConversion);
    MonetaryAmount money = Money.of(BigDecimal.TEN, DOLLAR);
    MonetaryAmount result = currencyConversion.apply(money);

    assertEquals(result.getCurrency(), EURO);
    assertTrue(result.getNumber().doubleValue() > 0);

}
 
开发者ID:JavaMoney,项目名称:jsr354-ri-bp,代码行数:13,代码来源:ECBHistoric90RateProviderTest.java

示例10: shouldConvertsDollarToEuro

import javax.money.convert.CurrencyConversion; //导入方法依赖的package包/类
@Test
public void shouldConvertsDollarToEuro() {
    CurrencyConversion currencyConversion = provider
            .getCurrencyConversion(EURO);
    assertNotNull(currencyConversion);
    MonetaryAmount money = Money.of(BigDecimal.TEN, DOLLAR);
    MonetaryAmount result = currencyConversion.apply(money);

    assertEquals(result.getCurrency(), EURO);
    assertTrue(result.getNumber().doubleValue() > 0);

}
 
开发者ID:JavaMoney,项目名称:jsr354-ri-bp,代码行数:13,代码来源:IMFRateProviderTest.java

示例11: shouldConvertsDollarToBrazilian

import javax.money.convert.CurrencyConversion; //导入方法依赖的package包/类
@Test
public void shouldConvertsDollarToBrazilian() {
    CurrencyConversion currencyConversion = provider
            .getCurrencyConversion(BRAZILIAN_REAL);
    assertNotNull(currencyConversion);
    MonetaryAmount money = Money.of(BigDecimal.TEN, DOLLAR);
    MonetaryAmount result = currencyConversion.apply(money);

    assertEquals(result.getCurrency(), BRAZILIAN_REAL);
    assertTrue(result.getNumber().doubleValue() > 0);

}
 
开发者ID:JavaMoney,项目名称:jsr354-ri-bp,代码行数:13,代码来源:IMFRateProviderTest.java

示例12: shouldConvertsBrazilianToDollar

import javax.money.convert.CurrencyConversion; //导入方法依赖的package包/类
@Test
public void shouldConvertsBrazilianToDollar() {
    CurrencyConversion currencyConversion = provider
            .getCurrencyConversion(DOLLAR);
    assertNotNull(currencyConversion);
    MonetaryAmount money = Money.of(BigDecimal.TEN, BRAZILIAN_REAL);
    MonetaryAmount result = currencyConversion.apply(money);

    assertEquals(result.getCurrency(), DOLLAR);
    assertTrue(result.getNumber().doubleValue() > 0);

}
 
开发者ID:JavaMoney,项目名称:jsr354-ri,代码行数:13,代码来源:IMFHistoricRateProviderTest.java

示例13: shouldReturnErrorWhenDoesNotFindTheExchangeRate

import javax.money.convert.CurrencyConversion; //导入方法依赖的package包/类
@Test(expectedExceptions = MonetaryException.class)
  public void shouldReturnErrorWhenDoesNotFindTheExchangeRate() {


      LocalDate localDate = YearMonth.of(2011, Month.JANUARY).atDay(9);
ConversionQuery conversionQuery = HistoricConversionQueryBuilder
		.of(EURO).withDay(localDate).build();
      CurrencyConversion currencyConversion = provider
              .getCurrencyConversion(conversionQuery);
      assertNotNull(currencyConversion);
      MonetaryAmount money = Money.of(BigDecimal.TEN, DOLLAR);
      currencyConversion.apply(money);
      fail();
  }
 
开发者ID:JavaMoney,项目名称:javamoney-shelter,代码行数:15,代码来源:HistoricRateProviderTest.java


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