Class CurrencyUtils


  • public class CurrencyUtils
    extends java.lang.Object
    The class provides some utility methods related to Currency functionality.
    • Constructor Summary

      Constructors 
      Constructor Description
      CurrencyUtils()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.math.BigDecimal applyRounding​(java.math.BigDecimal price, java.lang.String currencyIsoCode)
      Applies the scaling and rounding to a given price, based on declared currency code
      java.math.BigDecimal convertCurrency​(java.lang.String sourceCurrencyIsoCode, java.lang.String targetCurrencyIsoCode, java.math.BigDecimal sourceValue)
      Given the source and target currency codes, converts the value from one currency to another
      protected CommonI18NService getCommonI18NService()  
      CurrencyModel getCurrency​(java.lang.String currencyCode)
      Provides an instance of CurrencyModel for a given currency code
      java.util.Optional<java.lang.Integer> getDigitsOfCurrency​(java.lang.String currencyIsoCode)
      Provides number of digits defined for the currency that identifies itself by the provided currency iso code
      java.lang.Integer getDigitsOfCurrencyOrDefault​(java.lang.String currencyIsoCode)
      Provides number of digits defined for the currency that identifies itself by the provided currency iso code
      void setCommonI18NService​(CommonI18NService commonI18NService)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • CurrencyUtils

        public CurrencyUtils()
    • Method Detail

      • applyRounding

        public java.math.BigDecimal applyRounding​(java.math.BigDecimal price,
                                                  java.lang.String currencyIsoCode)
        Applies the scaling and rounding to a given price, based on declared currency code
        Parameters:
        price - - the value to apply the rounding to
        currencyIsoCode - - currency code
        Returns:
        the rounded price
      • convertCurrency

        public java.math.BigDecimal convertCurrency​(java.lang.String sourceCurrencyIsoCode,
                                                    java.lang.String targetCurrencyIsoCode,
                                                    java.math.BigDecimal sourceValue)
        Given the source and target currency codes, converts the value from one currency to another
        Parameters:
        sourceCurrencyIsoCode - - source currency code
        targetCurrencyIsoCode - - target currency code
        sourceValue - - the source value to apply the conversion for
        Returns:
        the converted value
      • getDigitsOfCurrency

        public java.util.Optional<java.lang.Integer> getDigitsOfCurrency​(java.lang.String currencyIsoCode)
        Provides number of digits defined for the currency that identifies itself by the provided currency iso code
        Parameters:
        currencyIsoCode - currency ISO code
        Returns:
        number of digits for the currency identified by the provided currency code
      • getDigitsOfCurrencyOrDefault

        public java.lang.Integer getDigitsOfCurrencyOrDefault​(java.lang.String currencyIsoCode)
        Provides number of digits defined for the currency that identifies itself by the provided currency iso code
        Parameters:
        currencyIsoCode - currency ISO code
        Returns:
        number of digits for the currency identified by the provided currency code or default value
      • getCurrency

        public CurrencyModel getCurrency​(java.lang.String currencyCode)
        Provides an instance of CurrencyModel for a given currency code
        Parameters:
        currencyCode - currency code
        Returns:
        instance of CurrencyModel that matches provided currency code
      • setCommonI18NService

        public void setCommonI18NService​(CommonI18NService commonI18NService)