Package com.avoka.core.util
Class CurrencyUtils
java.lang.Object
com.avoka.core.util.CurrencyUtils
Provides currency conversion utility methods using BigDecimal operations.
https://blogs.oracle.com/CoreJavaTechTips/entry/the_need_for_bigdecimal
- Since:
- 3.6.0
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic String
convertCentsToDollarAmount
(int centsAmount) Convert the cents amount into a dollar amount.static int
convertDollarAmountToCents
(double dollarAmount) Convert the dollar amount into cents, rounding to nearest cent value.static Integer
convertDollarAmountToCents
(String amountDollarStr) Convert the string dollar amount into cents, rounding to nearest cent value.static String
toShortDisplayValue
(double dollarAmount, Locale locale) Return a short currency display value for the give dollar amount and locale.
-
Constructor Details
-
CurrencyUtils
public CurrencyUtils()
-
-
Method Details
-
convertDollarAmountToCents
public static int convertDollarAmountToCents(double dollarAmount) Convert the dollar amount into cents, rounding to nearest cent value.- Parameters:
dollarAmount
- the decimal dollar amount- Returns:
- the amount in cents
-
convertCentsToDollarAmount
Convert the cents amount into a dollar amount.- Parameters:
centsAmount
- the amount in cents- Returns:
- the dollar amount as a string value
-
convertDollarAmountToCents
Convert the string dollar amount into cents, rounding to nearest cent value.- Parameters:
amountDollarStr
- the string representation of the payment amount- Returns:
- the payment amount in cents, or null if amountDollarStr is null or blank
- Since:
- 4.0.0
-
toShortDisplayValue
Return a short currency display value for the give dollar amount and locale.- Parameters:
dollarAmount
- the dollar amountlocale
- the currency locale- Returns:
- a short currency display value for the give dollar amount and locale.
- Since:
- 4.1.0
-