Tabnine Logo
ExchangeRateProvider.getCurrencyConversion
Code IndexAdd Tabnine to your IDE (free)

How to use
getCurrencyConversion
method
in
javax.money.convert.ExchangeRateProvider

Best Java code snippets using javax.money.convert.ExchangeRateProvider.getCurrencyConversion (Showing top 8 results out of 315)

origin: javax.money/money-api

/**
 * Access a {@link CurrencyConversion} that can be applied as a
 * {@link MonetaryOperator} to an amount.
 *
 * @param termCode terminal/target currency code, not {@code null}
 * @return a new instance of a corresponding {@link CurrencyConversion},
 * never {@code null}.
 * @throws MonetaryException if one of the currency codes passed is not valid.
 */
default CurrencyConversion getCurrencyConversion(String termCode){
  return getCurrencyConversion(Monetary.getCurrency(termCode));
}
origin: javax.money/money-api

/**
 * Access an instance of {@link CurrencyConversion}.
 *
 * @param conversionQuery the {@link javax.money.convert.ConversionQuery} determining the type of conversion
 *                        required, not null.
 * @return the corresponding conversion, not null.
 * @throws javax.money.MonetaryException if no matching conversion could be found.
 * @see #isConversionAvailable(javax.money.convert.ConversionQuery)
 */
default CurrencyConversion getConversion(ConversionQuery conversionQuery) {
  return getExchangeRateProvider(conversionQuery).getCurrencyConversion(
      Objects.requireNonNull(conversionQuery.getCurrency(), "Terminating Currency is required.")
  );
}
origin: javax.money/money-api

/**
 * Access a {@link CurrencyConversion} that can be applied as a
 * {@link MonetaryOperator} to an amount.
 *
 * @param term term {@link CurrencyUnit}, not {@code null}
 * @return a new instance of a corresponding {@link CurrencyConversion},
 * never {@code null}.
 */
default CurrencyConversion getCurrencyConversion(CurrencyUnit term){
  return getCurrencyConversion(ConversionQueryBuilder.of().setTermCurrency(term).build());
}
origin: JavaMoney/javamoney-examples

public static void main(String[] args) {
  ExchangeRateProvider imfRateProvider = MonetaryConversions
      .getExchangeRateProvider("IMF");
  ExchangeRateProvider ecbRateProvider = MonetaryConversions
      .getExchangeRateProvider("ECB");
  CurrencyUnit real = Monetary.getCurrency("BRL");
  CurrencyUnit dollar = Monetary.getCurrency(Locale.US);
  CurrencyConversion ecbDollarConvertion = ecbRateProvider
      .getCurrencyConversion(dollar);
  CurrencyConversion imfDollarConvertion = imfRateProvider
      .getCurrencyConversion(dollar);
  MonetaryAmount money = Money.of(10, real);
  System.out.println(money.with(ecbDollarConvertion));
  System.out.println(money.with(imfDollarConvertion));
}
origin: org.javamoney.moneta/moneta-core

/**
 * comparator to sort the {@link MonetaryAmount} considering the
 * {@link ExchangeRate}
 * @param provider the rate provider to be used, not null.
 * @return the sort of {@link MonetaryAmount} using {@link ExchangeRate}
 */
public static Comparator<? super MonetaryAmount> sortValuable(
    ExchangeRateProvider provider) {
  return (m1, m2) -> {
    CurrencyConversion conversion = provider.getCurrencyConversion(m1
        .getCurrency());
    return m1.compareTo(conversion.apply(m2));
  };
}
origin: org.javamoney.moneta/moneta-core

/**
 * return the sum and convert all values to specific currency using the
 * provider, if necessary
 * @param provider the rate provider to be used, not null.
 * @param currency
 *            currency
 * @return the list convert to specific currency unit
 */
public static BinaryOperator<MonetaryAmount> sum(
    ExchangeRateProvider provider, CurrencyUnit currency) {
  CurrencyConversion currencyConversion = provider
      .getCurrencyConversion(currency);
  return (m1, m2) -> currencyConversion.apply(m1).add(
      currencyConversion.apply(m2));
}
origin: org.javamoney.moneta/moneta-core

/**
 * return the minimum value, if the monetary amounts have different
 * currencies, will converter first using the given ExchangeRateProvider
 * @param provider
 *            the ExchangeRateProvider to convert the currencies
 * @return the minimum value
 */
public static BinaryOperator<MonetaryAmount> min(
    ExchangeRateProvider provider) {
  return (m1, m2) -> {
    CurrencyConversion conversion = provider.getCurrencyConversion(m1
        .getCurrency());
    if (m1.isGreaterThan(conversion.apply(m2))) {
      return m2;
    }
    return m1;
  };
}
origin: org.javamoney.moneta/moneta-core

/**
 * return the maximum value, if the monetary amounts have different
 * currencies, will converter first using the given ExchangeRateProvider
 * @param provider
 *            the ExchangeRateProvider to convert the currencies
 * @return the maximum value
 */
public static BinaryOperator<MonetaryAmount> max(
    ExchangeRateProvider provider) {
  return (m1, m2) -> {
    CurrencyConversion conversion = provider
        .getCurrencyConversion(m1.getCurrency());
    if (m1.isGreaterThan(conversion.apply(m2))) {
      return m1;
    }
    return m2;
  };
}
javax.money.convertExchangeRateProvidergetCurrencyConversion

Javadoc

Access a CurrencyConversion that can be applied as a MonetaryOperator to an amount.

Popular methods of ExchangeRateProvider

  • getExchangeRate
  • getContext
    Access the ConversionContext for this ExchangeRateProvider. Each instance of ExchangeRateProvider pr
  • isAvailable
    Checks if an ExchangeRate between two CurrencyUnit is available from this provider. This method shou

Popular in Java

  • Making http post requests using okhttp
  • runOnUiThread (Activity)
  • onRequestPermissionsResult (Fragment)
  • setScale (BigDecimal)
  • Graphics2D (java.awt)
    This Graphics2D class extends the Graphics class to provide more sophisticated control overgraphics
  • IOException (java.io)
    Signals a general, I/O-related error. Error details may be specified when calling the constructor, a
  • Stack (java.util)
    Stack is a Last-In/First-Out(LIFO) data structure which represents a stack of objects. It enables u
  • Manifest (java.util.jar)
    The Manifest class is used to obtain attribute information for a JarFile and its entries.
  • ZipFile (java.util.zip)
    This class provides random read access to a zip file. You pay more to read the zip file's central di
  • IOUtils (org.apache.commons.io)
    General IO stream manipulation utilities. This class provides static utility methods for input/outpu
  • Top 12 Jupyter Notebook extensions
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now