Class CurrencyFormatter

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

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

    Modifier and Type
    Method
    Description
    static @NotNull String
    format(@NotNull String symbol, double amount)
    Formats a currency amount based on the provided ISO currency symbol and amount.
    static @NotNull String
    format(@NotNull String symbol, double amount, boolean rounded)
    Formats a currency amount based on the provided ISO currency symbol, amount, and rounding preference.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • format

      @NotNull public static @NotNull String format(@NotNull @NotNull 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
      NullPointerException - if symbol is null
    • format

      @NotNull public static @NotNull String format(@NotNull @NotNull 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
      NoSuchElementException - if the currency symbol is not found in the registry
      NullPointerException - if symbol is null