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 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

      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 amount
      locale - the currency locale
      Returns:
      a short currency display value for the give dollar amount and locale.
      Since:
      4.1.0