Java Code Examples for javax.money.convert.MonetaryConversions#getExchangeRateProvider()
The following examples show how to use
javax.money.convert.MonetaryConversions#getExchangeRateProvider() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MonetaryConversionTest.java From jsr354-ri with Apache License 2.0 | 6 votes |
@Test public void testGetExchangeRateProvider_Chained() throws InterruptedException { ExchangeRateProvider prov = MonetaryConversions .getExchangeRateProvider("IMF"); assertTrue(Objects.nonNull(prov)); assertEquals(IMFRateProvider.class, prov.getClass()); // Test rate provided by IMF (derived) Thread.sleep(5000L); // wait for provider to load... ExchangeRate exchangeRate = prov.getExchangeRate(Monetary.getCurrency("USD"), Monetary.getCurrency("INR")); assertTrue(Objects.nonNull(exchangeRate)); assertTrue(exchangeRate.isDerived()); // Test rate provided by ECB exchangeRate = prov.getExchangeRate(Monetary.getCurrency("EUR"), Monetary.getCurrency("CHF")); assertTrue(Objects.nonNull(exchangeRate)); assertTrue(exchangeRate.isDerived()); }
Example 2
Source File: ExchangeRateAccess.java From javamoney-examples with Apache License 2.0 | 6 votes |
public static void main(String... args){ System.out.println("Default conversion chain -> " + MonetaryConversions.getDefaultConversionProviderChain()); ExchangeRateProvider provider = MonetaryConversions.getExchangeRateProvider("IDENT"); System.out.println("IDENT provider -> " + provider); provider = MonetaryConversions.getExchangeRateProvider("IDENT", "ECB"); System.out.println("IDENT, ECB provider -> " + provider); System.out.println(provider.getExchangeRate("CHF", "EUR")); System.out.println(provider.getExchangeRate("CHF", "CHF")); provider = MonetaryConversions.getExchangeRateProvider("IDENT", "IMF"); System.out.println(provider.getExchangeRate("TND", "BRL")); provider = MonetaryConversions.getExchangeRateProvider("IDENT", "ECB", "ECB-HIST"); System.out.println("CHF -> EUR (today) -> " + provider.getExchangeRate(ConversionQueryBuilder.of() .setBaseCurrency("EUR").setTermCurrency("CHF") .set(LocalDate.of(2008, 1, 8)).build())); System.out.println("CHF -> EUR (1.8.2008) -> " + provider.getExchangeRate(ConversionQueryBuilder.of() .setBaseCurrency("EUR").setTermCurrency("CHF") .set(LocalDate.of(2008, 1, 8)).build())); }
Example 3
Source File: MonetaryConversionTest.java From javamoney-examples with Apache License 2.0 | 6 votes |
@Test public void testGetExchangeRateProvider_Chained() throws InterruptedException { ExchangeRateProvider prov = MonetaryConversions .getExchangeRateProvider("ECB", "IMF"); assertTrue(prov != null); assertEquals(CompoundRateProvider.class, prov.getClass()); // Test rate provided by IMF (derived) Thread.sleep(5000L); // wait for provider to load... ExchangeRate r = prov.getExchangeRate(Monetary.getCurrency("USD"), Monetary.getCurrency("INR")); assertTrue(r != null); assertTrue(r.isDerived()); // Test rate provided by ECB r = prov.getExchangeRate(Monetary.getCurrency("EUR"), Monetary.getCurrency("CHF")); assertTrue(r != null); assertFalse(r.isDerived()); }
Example 4
Source File: ExchangeRateAccess.java From javamoney-examples with Apache License 2.0 | 6 votes |
public static void main(String... args){ System.out.println("Default conversion chain -> " + MonetaryConversions.getDefaultConversionProviderChain()); ExchangeRateProvider provider = MonetaryConversions.getExchangeRateProvider("IDENT"); System.out.println("IDENT provider -> " + provider); provider = MonetaryConversions.getExchangeRateProvider("IDENT", "ECB"); System.out.println("IDENT, ECB provider -> " + provider); System.out.println(provider.getExchangeRate("CHF", "EUR")); System.out.println(provider.getExchangeRate("CHF", "CHF")); provider = MonetaryConversions.getExchangeRateProvider("IDENT", "IMF"); System.out.println(provider.getExchangeRate("TND", "BRL")); provider = MonetaryConversions.getExchangeRateProvider("IDENT", "ECB", "ECB-HIST"); System.out.println("CHF -> EUR (today) -> " + provider.getExchangeRate(ConversionQueryBuilder.of() .setBaseCurrency("EUR").setTermCurrency("CHF") //.set(new Date() LocalDate.of(2008, 1, 8)) .build())); System.out.println("CHF -> EUR (1.8.2008) -> " + provider.getExchangeRate(ConversionQueryBuilder.of() .setBaseCurrency("EUR").setTermCurrency("CHF") //.set(LocalDate.of(2008, 1, 8)) .build())); }
Example 5
Source File: ExchangeExample.java From javamoney-examples with Apache License 2.0 | 6 votes |
public static void main(String[] args) { ExchangeRateProvider imfRateProvider = MonetaryConversions .getExchangeRateProvider("IMF"); ExchangeRateProvider ecbRateProvider = MonetaryConversions .getExchangeRateProvider("ECB"); CurrencyUnit euro = Monetary.getCurrency("EUR"); CurrencyUnit dollar = Monetary.getCurrency(Locale.US); CurrencyConversion ecbDollarConvertion = ecbRateProvider .getCurrencyConversion(dollar); CurrencyConversion imfDollarConvertion = imfRateProvider .getCurrencyConversion(dollar); MonetaryAmount money = Money.of(10, euro); System.out.println(money.with(ecbDollarConvertion)); System.out.println(money.with(imfDollarConvertion)); }
Example 6
Source File: MonetaryConversionTest.java From jsr354-ri with Apache License 2.0 | 6 votes |
@Test public void testGetExchangeRateProvider_Chained() throws InterruptedException { ExchangeRateProvider prov = MonetaryConversions .getExchangeRateProvider("ECB"); assertTrue(Objects.nonNull(prov)); assertEquals(ECBCurrentRateProvider.class, prov.getClass()); // Test rate provided by IMF (derived) Thread.sleep(5000L); // wait for provider to load... ExchangeRate r = prov.getExchangeRate(Monetary.getCurrency("USD"), Monetary.getCurrency("INR")); assertTrue(Objects.nonNull(r)); assertTrue(r.isDerived()); // Test rate provided by ECB r = prov.getExchangeRate(Monetary.getCurrency("EUR"), Monetary.getCurrency("CHF")); assertTrue(Objects.nonNull(r)); assertFalse(r.isDerived()); }
Example 7
Source File: ExchangeRateTypeTest.java From jsr354-ri with Apache License 2.0 | 5 votes |
@Test public void shouldReturnsECBCurrentRateProvider() { ExchangeRateProvider prov = MonetaryConversions .getExchangeRateProvider(ExchangeRateType.ECB); assertTrue(Objects.nonNull(prov)); assertEquals(ECBCurrentRateProvider.class, prov.getClass()); }
Example 8
Source File: ExchangeRateTypeTest.java From jsr354-ri with Apache License 2.0 | 5 votes |
@Test public void shouldReturnsECBHistoricRateProvider() { ExchangeRateProvider prov = MonetaryConversions .getExchangeRateProvider(ExchangeRateType.ECB_HIST); assertTrue(Objects.nonNull(prov)); assertEquals(ECBHistoricRateProvider.class, prov.getClass()); }
Example 9
Source File: ExchangeRateTypeTest.java From jsr354-ri with Apache License 2.0 | 5 votes |
@Test public void shouldReturnsECBHistoric90RateProvider() { ExchangeRateProvider prov = MonetaryConversions .getExchangeRateProvider(ExchangeRateType.ECB_HIST90); assertTrue(Objects.nonNull(prov)); assertEquals(ECBHistoric90RateProvider.class, prov.getClass()); }
Example 10
Source File: MonetaryConversionTest.java From jsr354-ri with Apache License 2.0 | 5 votes |
@Test public void testGetExchangeRateDefault() { ExchangeRateProvider prov = MonetaryConversions .getExchangeRateProvider(); assertTrue(Objects.nonNull(prov)); ExchangeRate rate = prov.getExchangeRate("CHF", "EUR"); assertNotNull(rate); }
Example 11
Source File: USFederalReserveExchangeRateTypeTest.java From javamoney-lib with Apache License 2.0 | 5 votes |
@Test public void shouldReturnsFRBRateProvider() { ExchangeRateProvider prov = MonetaryConversions .getExchangeRateProvider("FRB"); assertTrue(Objects.nonNull(prov)); assertEquals(USFederalReserveRateProvider.class, prov.getClass()); }
Example 12
Source File: ExchangeRateTypeTest.java From jsr354-ri with Apache License 2.0 | 5 votes |
@Test public void shouldReturnsIMFRateProvider() { ExchangeRateProvider prov = MonetaryConversions .getExchangeRateProvider(ExchangeRateType.IMF); assertTrue(Objects.nonNull(prov)); assertEquals(IMFRateProvider.class, prov.getClass()); }
Example 13
Source File: ExchangeRateTypeTest.java From jsr354-ri with Apache License 2.0 | 5 votes |
@Test public void shouldReturnsIMFHistoricRateProvider() { ExchangeRateProvider prov = MonetaryConversions .getExchangeRateProvider(ExchangeRateType.IMF_HIST); assertTrue(Objects.nonNull(prov)); assertEquals(IMFHistoricRateProvider.class, prov.getClass()); }
Example 14
Source File: MonetaryConversionTest.java From javamoney-examples with Apache License 2.0 | 5 votes |
@Test public void testGetExchangeRateDefault() { ExchangeRateProvider prov = MonetaryConversions .getExchangeRateProvider(); assertTrue(Objects.nonNull(prov)); ExchangeRate rate = prov.getExchangeRate("CHF", "EUR"); assertNotNull(rate); }
Example 15
Source File: MonetaryConversionTest.java From javamoney-examples with Apache License 2.0 | 5 votes |
@Test public void testGetExchangeRateProvider() { ExchangeRateProvider prov = MonetaryConversions .getExchangeRateProvider("ECB"); assertTrue(Objects.nonNull(prov)); assertEquals(ECBCurrentRateProvider.class, prov.getClass()); }
Example 16
Source File: ExchangeRateTypeTest.java From javamoney-lib with Apache License 2.0 | 5 votes |
@Test public void shouldReturnsYahooRateProviderFromType() { ExchangeRateProvider prov = MonetaryConversions .getExchangeRateProvider(YahooExchangeRateType.YAHOO); assertTrue(Objects.nonNull(prov)); assertEquals(YahooRateProvider.class, prov.getClass()); }
Example 17
Source File: MonetaryConversionTest.java From javamoney-examples with Apache License 2.0 | 5 votes |
@Test public void testGetExchangeRateDefault() { ExchangeRateProvider prov = MonetaryConversions .getExchangeRateProvider(); assertTrue(prov != null); ExchangeRate rate = prov.getExchangeRate("CHF", "EUR"); assertNotNull(rate); }
Example 18
Source File: MonetaryConversionTest.java From javamoney-examples with Apache License 2.0 | 5 votes |
@Test public void testGetExchangeRateProvider() { ExchangeRateProvider prov = MonetaryConversions .getExchangeRateProvider("ECB"); assertTrue(prov != null); assertEquals(ECBCurrentRateProvider.class, prov.getClass()); }
Example 19
Source File: ExchangeRateTypeTest.java From javamoney-lib with Apache License 2.0 | 5 votes |
@Test public void shouldReturnsYahooRateProvider() { ExchangeRateProvider prov = MonetaryConversions .getExchangeRateProvider("YAHOO"); assertTrue(Objects.nonNull(prov)); assertEquals(YahooRateProvider.class, prov.getClass()); }
Example 20
Source File: USFederalReserveExchangeRateTypeTest.java From javamoney-lib with Apache License 2.0 | 5 votes |
@Test public void shouldReturnsFRBRateProviderFromType() { ExchangeRateProvider prov = MonetaryConversions .getExchangeRateProvider(USFederalReserveExchangeRateType.FRB); assertTrue(Objects.nonNull(prov)); assertEquals(USFederalReserveRateProvider.class, prov.getClass()); }