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.Listener
This class implements an ExchangeRateProvider
that 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
FieldsModifier and TypeFieldDescriptionstatic final CurrencyUnitBase currency of the loaded rates is always EUR.protected CountDownLatchprotected Stringprotected final Map<LocalDate,Map<String, ExchangeRate>> Historic exchange rates, rate timestamp as UTC long.protected final StringFields inherited from class org.javamoney.moneta.spi.AbstractRateProvider
log -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected LoadDataInformationGets the default data loading configuration.getExchangeRate(ConversionQuery conversionQuery) voidnewDataLoaded(String resourceId, InputStream is) toString()Methods inherited from class org.javamoney.moneta.spi.AbstractRateProvider
divide, divide, getContext, getCurrencyConversion, getExchangeContext, getQueryDates, getScale, multiplyMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface javax.money.convert.ExchangeRateProvider
getCurrencyConversion, getCurrencyConversion, getExchangeRate, getExchangeRate, getReversed, isAvailable, isAvailable, isAvailable
-
Field Details
-
BASE_CURRENCY
Base currency of the loaded rates is always EUR. -
rates
Historic exchange rates, rate timestamp as UTC long. -
loadState
-
loadLock
-
remoteResource
-
-
Constructor Details
-
ECBHistoricRateProvider
public ECBHistoricRateProvider()
-
-
Method Details
-
getDataId
-
getDefaultLoadData
Gets the default data loading configuration. This configuration is used if no other is provided.- Returns:
- the configuration
-
newDataLoaded
- Specified by:
newDataLoadedin interfaceLoaderService.Listener
-
getExchangeRate
- Specified by:
getExchangeRatein interfaceExchangeRateProvider- Specified by:
getExchangeRatein classAbstractRateProvider
-
toString
-