Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
com.posadskiy:currency-converter
Advanced tools
Java library receives current exchange rate
<dependency>
<groupId>com.posadskiy</groupId>
<artifactId>currency-converter</artifactId>
<version>1.3.1</version>
</dependency>
compile 'com.posadskiy:currency-converter:1.3.1'
libraryDependencies += "com.posadskiy" % "currency-converter" % "1.3.1"
/**
* Define your API keys
* Use at least one key, but we recommend define three:
* One or even two services can be off, but not three at the same time
*/
public static final String CURRENCY_CONVERTER_API_API_KEY = "YOUR API KEY FOR CurrencyConverterApi.Com";
public static final String CURRENCY_LAYER = "YOUR API KEY FOR CurrencyLayer.Com";
public static final String OPEN_EXCHANGE_RATES = "YOUR API KEY FOR OpenExchangeRates.Com";
// Init converter with your API key
CurrencyConverter converter = new CurrencyConverter(
new ConfigBuilder()
.currencyConverterApiApiKey(CURRENCY_CONVERTER_API_API_KEY)
.currencyLayerApiKey(CURRENCY_LAYER)
.openExchangeRatesApiKey(OPEN_EXCHANGE_RATES)
.build()
);
Only one service using (recommended using at least two, it helps when one is unavailable)
public static final String OPEN_EXCHANGE_RATES = "YOUR API KEY FOR OpenExchangeRates.Com";
CurrencyConverter converter = new CurrencyConverter(
new ConfigBuilder()
.openExchangeRatesApiKey(OPEN_EXCHANGE_RATES)
.build()
);
// Get rate with Currency Enum
Double gbrToChfRate = converter.rate(Currency.GBP, Currency.CHF);
// Get rate with half fixed method
Double usdToEuroRate = converter.rateFromUsd(Currency.EUR);
// Get rate with fixed method
Double usdToEuroRate = converter.rateFromUsdToEuro();
// Get rate with String parameters
Double usdToEuroRate = converter.rate("USD", "EUR");
Sign up on websites you are going to use:
and get key for use this services.
API key looks like symbolic string.
The working process for Android is different from the usual Java application. Network requests from the main tread are prohibited for Android, so a possible way to call Currency Converter library is by creating AsyncTask wrapper. See Examples.
Also, it should be noted, Android application should have permissions to interaction with Network. Add to AndroidManifest.xml:
<uses-permission android:name="android.permission.INTERNET"/>
Currency Converter is available under the MIT license.
FAQs
Open Source library for converting currencies
We found that com.posadskiy:currency-converter demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.