Class CurrencyUtils
- java.lang.Object
-
- de.hybris.platform.ruleengineservices.util.CurrencyUtils
-
public class CurrencyUtils extends java.lang.ObjectThe 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.BigDecimalapplyRounding(java.math.BigDecimal price, java.lang.String currencyIsoCode)Applies the scaling and rounding to a given price, based on declared currency codejava.math.BigDecimalconvertCurrency(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 anotherprotected CommonI18NServicegetCommonI18NService()CurrencyModelgetCurrency(java.lang.String currencyCode)Provides an instance ofCurrencyModelfor a given currency codejava.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 codejava.lang.IntegergetDigitsOfCurrencyOrDefault(java.lang.String currencyIsoCode)Provides number of digits defined for the currency that identifies itself by the provided currency iso codevoidsetCommonI18NService(CommonI18NService commonI18NService)
-
-
-
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 tocurrencyIsoCode- - 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 codetargetCurrencyIsoCode- - target currency codesourceValue- - 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 ofCurrencyModelfor a given currency code- Parameters:
currencyCode- currency code- Returns:
- instance of
CurrencyModelthat matches provided currency code
-
getCommonI18NService
protected CommonI18NService getCommonI18NService()
-
setCommonI18NService
public void setCommonI18NService(CommonI18NService commonI18NService)
-
-