Package com.avoka.core.util
Class CurrencyUtils
- java.lang.Object
-
- com.avoka.core.util.CurrencyUtils
-
public class CurrencyUtils extends Object
Provides currency conversion utility methods using BigDecimal operations. https://blogs.oracle.com/CoreJavaTechTips/entry/the_need_for_bigdecimal- Since:
- 3.6.0
-
-
Constructor Summary
Constructors Constructor Description CurrencyUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static 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.
-
-
-
Method Detail
-
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
public static String convertCentsToDollarAmount(int centsAmount)
Convert the cents amount into a dollar amount.- Parameters:
centsAmount
- the amount in cents- Returns:
- the dollar amount as a string value
-
convertDollarAmountToCents
public static Integer convertDollarAmountToCents(String amountDollarStr)
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
public static String toShortDisplayValue(double dollarAmount, Locale locale)
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
-
-