Class CurrencyFormatter

java.lang.Object
net.thauvin.erik.frankfurter.CurrencyFormatter

public final class CurrencyFormatter extends Object
Utility class for formatting currency values.
  • Method Details

    • format

      public static String format(String symbol, Double amount)
      Formats a currency amount based on the provided ISO currency symbol and amount.
      Parameters:
      symbol - the 3-letter ISO currency symbol (e.g., "USD", "EUR")
      amount - the monetary amount to format
      Returns:
      a formatted currency string
      Throws:
      IllegalArgumentException - if the currency symbol is unknown or invalid
    • format

      public static String format(String symbol, Double amount, boolean rounded)
      Formats a currency amount based on the provided ISO currency symbol, amount, and rounding preference.
      Parameters:
      symbol - the 3-letter ISO currency symbol (e.g., "USD", "EUR")
      amount - the monetary amount to format
      rounded - Whether to round the amount
      Returns:
      a formatted currency string
      Throws:
      IllegalArgumentException - if the currency symbol is unknown or invalid