Package org.javamoney.moneta.convert.ecb
Class ECBHistoricRateProvider
- java.lang.Object
-
- org.javamoney.moneta.spi.AbstractRateProvider
-
- org.javamoney.moneta.convert.ecb.ECBHistoricRateProvider
-
- All Implemented Interfaces:
ExchangeRateProvider,LoaderService.LoaderListener
public class ECBHistoricRateProvider extends AbstractRateProvider
This class implements an
ExchangeRateProviderthat loads data from the European Central Bank data feed (XML). It loads the current exchange rates, as well as historic rates for the past 1500 days. The provider loads all data up to 1999 into its historic data cache.The default date is yesterday or the most recent day of week. To uses exchange rate from a specific date, you can use this way:
CurrencyUnit termCurrency = ...;LocalDate localDate = ...;ConversionQuery conversionQuery = ConversionQueryBuilder.of().setTermCurrency(euro).set(localDate).build();CurrencyConversion currencyConversion = provider.getCurrencyConversion(conversionQuery);MonetaryAmount money = ...;MonetaryAmount result = currencyConversion.apply(money);- Author:
- Anatole Tresch, Werner Keil, otaviojava
-
-
Field Summary
Fields Modifier and Type Field Description static CurrencyUnitBASE_CURRENCYBase currency of the loaded rates is always EUR.protected CountDownLatchloadLockprotected StringloadStateprotected Map<LocalDate,Map<String,ExchangeRate>>ratesHistoric exchange rates, rate timestamp as UTC long.-
Fields inherited from class org.javamoney.moneta.spi.AbstractRateProvider
log
-
-
Constructor Summary
Constructors Constructor Description ECBHistoricRateProvider()
-
Method Summary
Modifier and Type Method Description StringgetDataId()ExchangeRategetExchangeRate(ConversionQuery conversionQuery)voidnewDataLoaded(String resourceId, InputStream is)StringtoString()-
Methods inherited from class org.javamoney.moneta.spi.AbstractRateProvider
divide, divide, getContext, getCurrencyConversion, getExchangeContext, getQueryDates, getScale, multiply
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface javax.money.convert.ExchangeRateProvider
getCurrencyConversion, getCurrencyConversion, getExchangeRate, getExchangeRate, getReversed, isAvailable, isAvailable, isAvailable
-
-
-
-
Field Detail
-
BASE_CURRENCY
public static final CurrencyUnit BASE_CURRENCY
Base currency of the loaded rates is always EUR.
-
rates
protected final Map<LocalDate,Map<String,ExchangeRate>> rates
Historic exchange rates, rate timestamp as UTC long.
-
loadState
protected volatile String loadState
-
loadLock
protected volatile CountDownLatch loadLock
-
-
Constructor Detail
-
ECBHistoricRateProvider
public ECBHistoricRateProvider()
-
-
Method Detail
-
newDataLoaded
public void newDataLoaded(String resourceId, InputStream is)
- Specified by:
newDataLoadedin interfaceLoaderService.LoaderListener
-
getExchangeRate
public ExchangeRate getExchangeRate(ConversionQuery conversionQuery)
- Specified by:
getExchangeRatein interfaceExchangeRateProvider- Specified by:
getExchangeRatein classAbstractRateProvider
-
-