Package com.erudika.para.core.i18n
Enum Class CurrencyUtils
- All Implemented Interfaces:
Serializable,Comparable<CurrencyUtils>,Constable
Helper utility class for currency operations.
- Author:
- Alex Bogdanovski [[email protected]]
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>> -
Enum Constant Summary
Enum Constants -
Method Summary
Modifier and TypeMethodDescriptionabstract StringformatPrice(Double price, String cur) Formats a price for its specific locale, depending on the currency code.Returns a map of all available currencies in the form: currency code - full currency name and symbol.abstract CurrencygetCurrency(String cur) Returns the currency instance for a given currency code.abstract CurrencygetCurrency(Locale loc) Returns the currency instance for a given locale.abstract StringgetCurrencyName(String cur, Locale locale) Returns the full name of the currency in the language of the given locale.static CurrencyUtilsReturns an instance of this class.abstract LocalegetLocaleForCountry(String countryCode) Returns the locale for a given country code.abstract booleanisValidCurrency(String cur) Validate the currency code.static CurrencyUtilsReturns the enum constant of this class with the specified name.static CurrencyUtils[]values()Returns an array containing the constants of this enum class, in the order they are declared.Methods inherited from class java.lang.Enum
compareTo, describeConstable, equals, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
-
Enum Constant Details
-
INSTANCE
Singleton.
-
-
Method Details
-
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
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 nameNullPointerException- if the argument is null
-
formatPrice
Formats a price for its specific locale, depending on the currency code.- Parameters:
price- the amountcur- the 3-letter currency code- Returns:
- a formatted price with its currency symbol
-
getCurrencyName
Returns the full name of the currency in the language of the given locale. Defaults to English.- Parameters:
cur- the 3-letter currency codelocale- the locale- Returns:
- the currency name or "" if the currency is unknown
-
getLocaleForCountry
Returns the locale for a given country code.- Parameters:
countryCode- the 2-letter country code- Returns:
- a locale or null if countryCode is null
-
getCurrency
Returns the currency instance for a given currency code.- Parameters:
cur- the 3-letter currency code- Returns:
- the currency
-
getCurrency
Returns the currency instance for a given locale.- Parameters:
loc- locale- Returns:
- the currency instance or null if not found
-
getCurrenciesMap
Returns a map of all available currencies in the form: currency code - full currency name and symbol.- Returns:
- a map of known currencies
-
isValidCurrency
Validate the currency code.- Parameters:
cur- a 3-letter curency code- Returns:
- true if the code corresponds to a valid currency
-
getInstance
Returns an instance of this class.- Returns:
- an instance
-