blob: 6030f4c3c4fd896da62a974a9e249cc587138c31 [file] [log] [blame]
/**
*
* Copyright (c) 2011, 2016 - Loetz GmbH&Co.KG (69115 Heidelberg, Germany)
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Christophe Loetz (Loetz GmbH&Co.KG) - initial implementation
*/
package org.eclipse.osbp.utils.currency.test;
import java.util.Currency;
import java.util.Locale;
import org.joda.money.CurrencyUnit;
import org.eclipse.osbp.utils.currency.EuroBasedExchangeReferenceRates;
public class Sample {
public static void main(String[] args) {
Locale locale = Locale.getDefault();
System.err.println(locale+" = "+locale.getDisplayName());
CurrencyUnit current = CurrencyUnit.of(locale);
System.err.println(information(current));
System.err.println("total "+CurrencyUnit.registeredCurrencies().size()+" currencies");
for (CurrencyUnit available : CurrencyUnit.registeredCurrencies()) {
if (!current.equals(available)) {
System.err.println(information(available));
}
}
EuroBasedExchangeReferenceRates.loadEuroForeignExchangeReferenceRates();
System.err.println("total "+EuroBasedExchangeReferenceRates.registeredCurrencies().size()+" currencies");
for (CurrencyUnit available : EuroBasedExchangeReferenceRates.registeredCurrencies()) {
// if (!current.equals(available)) {
System.err.println(EuroBasedExchangeReferenceRates.getCurrencyConversionData(available).toString());
// }
}
EuroBasedExchangeReferenceRates.unloadEuroForeignExchangeReferenceRates();
}
private static String information(CurrencyUnit currencyUnit) {
Currency currency = currencyUnit.toCurrency();
return currencyUnit.getCode()+" = "+currencyUnit.getSymbol()+" = "+currency.getDisplayName()+" / "+currencyUnit.getDefaultFractionDigits()+" digits";
}
}