001/**
002 * Copyright (c) 2012, 2014, Credit Suisse (Anatole Tresch), Werner Keil and others by the @author tag.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
005 * use this file except in compliance with the License. You may obtain a copy of
006 * the License at
007 *
008 * http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
012 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
013 * License for the specific language governing permissions and limitations under
014 * the License.
015 */
016package org.javamoney.moneta.internal.convert;
017
018import java.net.MalformedURLException;
019
020import javax.money.convert.ProviderContext;
021import javax.money.convert.ProviderContextBuilder;
022import javax.money.convert.RateType;
023
024/**
025 * <p>
026 * This class implements an {@link javax.money.convert.ExchangeRateProvider}
027 * that loads data from the European Central Bank data feed (XML). It loads the
028 * current exchange rates, as well as historic rates for the past 90 days. The
029 * provider loads all data up to 1999 into its historic data cache.
030 * </p>
031 * <p>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:</p>
032 * <p><code>CurrencyUnit termCurrency = ...;</code></p>
033 * <p><code>LocalDate localDate = ...;</code></p>
034 * <p><code>ConversionQuery conversionQuery = ConversionQueryBuilder.of().setTermCurrency(euro).setTimestamp(localDate).build();</code>v
035 * <p><code>CurrencyConversion currencyConversion = provider.getCurrencyConversion(conversionQuery);</code></p>
036 * <p><code>MonetaryAmount money = ...;</code></p>
037 * <p><code>MonetaryAmount result = currencyConversion.apply(money);</code></p>
038 *
039 * @author Anatole Tresch
040 * @author Werner Keil
041 * @author otaviojava
042 */
043public class ECBHistoric90RateProvider extends AbstractECBRateProvider {
044
045
046    private static final String DATA_ID = ECBHistoric90RateProvider.class.getSimpleName();
047
048    private static final ProviderContext CONTEXT =
049            ProviderContextBuilder.of("ECB-HIST90", RateType.HISTORIC, RateType.DEFERRED)
050                    .set("providerDescription", "European Central Bank (last 90 days)").set("days", 90).build();
051
052    public ECBHistoric90RateProvider() {
053        super(CONTEXT);
054    }
055
056    @Override
057    public String getDataId() {
058        return DATA_ID;
059    }
060
061
062}