Class CurrencyUtils
- java.lang.Object
-
- de.hybris.platform.ruleengineservices.util.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 codejava.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 anotherprotected CommonI18NService
getCommonI18NService()
CurrencyModel
getCurrency(java.lang.String currencyCode)
Provides an instance ofCurrencyModel
for 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.Integer
getDigitsOfCurrencyOrDefault(java.lang.String currencyIsoCode)
Provides number of digits defined for the currency that identifies itself by the provided currency iso codevoid
setCommonI18NService(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 ofCurrencyModel
for a given currency code- Parameters:
currencyCode
- currency code- Returns:
- instance of
CurrencyModel
that matches provided currency code
-
getCommonI18NService
protected CommonI18NService getCommonI18NService()
-
setCommonI18NService
public void setCommonI18NService(CommonI18NService commonI18NService)
-
-