Class BroadleafCurrencyUtils
java.lang.Object
org.broadleafcommerce.common.currency.util.BroadleafCurrencyUtils
Utility methods for common currency operations
- Author:
- Phillip Verheyden
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final Map<String,NumberFormat> static final MathContext -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic intcalculateRemainder(Money totalAmount, int quantity) Returns the remainder amount if the passed in totalAmount was divided by the quantity taking into account the normal unit of the currency (e.g. .01 for US).static CurrencygetCurrency(BroadleafCurrency currency) static CurrencygetCurrency(Money money) static MoneygetMoney(BigDecimal amount) static MoneygetMoney(BigDecimal amount, BroadleafCurrency currency) static MoneygetMoney(BroadleafCurrency currency) static NumberFormatgetNumberFormatFromCache(Locale locale, Currency currency) Provides a cached approach for creating NumberFormat instances.static NumberFormatstatic MoneygetUnitAmount(BroadleafCurrency blCurrency) Returns the unit amount (e.g. .01 for US and all other 2 decimal currencies)static MoneygetUnitAmount(Money difference) Returns the unit amount (e.g. .01 for US and all other 2 decimal currencies)
-
Field Details
-
ROUND_FLOOR_MATH_CONTEXT
-
FORMAT_CACHE
-
-
Constructor Details
-
BroadleafCurrencyUtils
public BroadleafCurrencyUtils()
-
-
Method Details
-
getMoney
-
getMoney
-
getMoney
-
getCurrency
-
getCurrency
-
getUnitAmount
Returns the unit amount (e.g. .01 for US and all other 2 decimal currencies)- Parameters:
difference-- Returns:
-
getUnitAmount
Returns the unit amount (e.g. .01 for US and all other 2 decimal currencies)- Parameters:
blCurrency-- Returns:
-
calculateRemainder
Returns the remainder amount if the passed in totalAmount was divided by the quantity taking into account the normal unit of the currency (e.g. .01 for US).- Parameters:
totalAmount-quantity-- Returns:
-
getNumberFormatFromCache
Provides a cached approach for creating NumberFormat instances. More performant than creating a new one each time.- Parameters:
locale- the Localecurrency- the Currency- Returns:
- either a new NumberFormat instance, or one taken from the cache
-
getNumberFormatFromCache
-