public class ECBHistoric90RateProvider extends AbstractRateProvider
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 90 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).setTimestamp(localDate).build();
v
CurrencyConversion currencyConversion = provider.getCurrencyConversion(conversionQuery);
MonetaryAmount money = ...;
MonetaryAmount result = currencyConversion.apply(money);
Modifier and Type | Field and Description |
---|---|
static javax.money.CurrencyUnit |
BASE_CURRENCY
Base currency of the loaded rates is always EUR.
|
protected Map<java.time.LocalDate,Map<String,javax.money.convert.ExchangeRate>> |
rates
Historic exchange rates, rate timestamp as UTC long.
|
log
Constructor and Description |
---|
ECBHistoric90RateProvider() |
Modifier and Type | Method and Description |
---|---|
String |
getDataId() |
javax.money.convert.ExchangeRate |
getExchangeRate(javax.money.convert.ConversionQuery conversionQuery) |
protected java.time.LocalDate[] |
getQueryDates(javax.money.convert.ConversionQuery query) |
void |
newDataLoaded(String resourceId,
InputStream is)
Callback called from the
LoaderService , when new data was
read for a given data item. |
divide, divide, getContext, getCurrencyConversion, multiply
public static final javax.money.CurrencyUnit BASE_CURRENCY
public ECBHistoric90RateProvider()
public void newDataLoaded(String resourceId, InputStream is)
LoaderService.LoaderListener
LoaderService
, when new data was
read for a given data item.newDataLoaded
in interface LoaderService.LoaderListener
resourceId
- the resource idis
- the input stream for accessing the dataprotected java.time.LocalDate[] getQueryDates(javax.money.convert.ConversionQuery query)
public javax.money.convert.ExchangeRate getExchangeRate(javax.money.convert.ConversionQuery conversionQuery)
getExchangeRate
in interface javax.money.convert.ExchangeRateProvider
getExchangeRate
in class AbstractRateProvider
Copyright © 2012-2015 JavaMoney. All Rights Reserved.