Enum Class Currency

All Implemented Interfaces:
Serializable, Comparable<Currency>, Constable

public enum Currency extends Enum<Currency>
The Currency enum represents different currencies and provides methods for converting between them.

Includes methods for converting an amount from the currency to Euro and vice versa and a method to find a Currency by its display string.

  • Enum Constant Details Link icon

    • EURO Link icon

      public static final Currency EURO
      The Euro currency, last updated on 2024-12-01.
    • US_DOLLAR Link icon

      public static final Currency US_DOLLAR
      The US Dollar currency, last updated on 2024-12-01.
    • BRITISH_POUND Link icon

      public static final Currency BRITISH_POUND
      The British Pound currency, last updated on 2024-12-01.
  • Method Details Link icon

    • values Link icon

      public static Currency[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf Link icon

      public static Currency valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null
    • convertToDisplayString Link icon

      public String convertToDisplayString()
      Returns a user-friendly display string for the currency.
      Returns:
      the display string
    • getSymbol Link icon

      public String getSymbol()
      Returns the currency symbol.
      Returns:
      the currency symbol as a string
    • fromDisplayString Link icon

      public static Currency fromDisplayString(String displayString)
      Finds a Currency by its display string.
      Parameters:
      displayString - the display string to search for
      Returns:
      the corresponding Currency
      Throws:
      IllegalArgumentException - if no match is found
    • convertToEuro Link icon

      public double convertToEuro(double amount)
      Converts an amount from this currency to Euro, rounding to two decimal places.
      Parameters:
      amount - the amount to convert
      Returns:
      the amount in Euro
    • convertFromEuro Link icon

      public double convertFromEuro(double amount)
      Converts an amount from Euro to this currency, rounding to two decimal places.
      Parameters:
      amount - the amount to convert
      Returns:
      the amount in this currency