public class Currency extends MeasureUnit implements Serializable
Note: This class deliberately resembles java.util.Currency but it has a completely independent implementation, and adds features not present in the JDK.
| Modifier and Type | Field and Description |
|---|---|
static int |
LONG_NAME
Selector for ucurr_getName indicating the long name for a
currency, such as "US Dollar" for USD.
|
static int |
SYMBOL_NAME
Selector for getName() indicating a symbolic name for a
currency, such as "$" for USD.
|
| Modifier | Constructor and Description |
|---|---|
protected |
Currency(String theISOCode)
Constructs a currency object for the given ISO 4217 3-letter
code.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
equals(Object rhs)
Return true if rhs is a Currency instance,
is non-null, and has the same currency code.
|
static Locale[] |
getAvailableLocales()
Return an array of the locales for which a currency
is defined.
|
static ULocale[] |
getAvailableULocales()
Return an array of the ulocales for which a currency
is defined.
|
String |
getCurrencyCode()
Returns the ISO 4217 3-letter code for this currency object.
|
int |
getDefaultFractionDigits()
Returns the number of the number of fraction digits that should
be displayed for this currency.
|
static Currency |
getInstance(Locale locale)
Returns a currency object for the default currency in the given
locale.
|
static Currency |
getInstance(String theISOCode)
Returns a currency object given an ISO 4217 3-letter code.
|
static Currency |
getInstance(ULocale locale)
Returns a currency object for the default currency in the given
locale.
|
ULocale |
getLocale(ULocale.Type type)
Deprecated.
This API is obsolete.
|
String |
getName(Locale locale,
int nameStyle,
boolean[] isChoiceFormat)
Returns the display name for the given currency in the
given locale.
|
String |
getName(ULocale locale,
int nameStyle,
boolean[] isChoiceFormat)
Returns the display name for the given currency in the
given locale.
|
double |
getRoundingIncrement()
Returns the rounding increment for this currency, or 0.0 if no
rounding is done by this currency.
|
String |
getSymbol()
Convenience and compatibility override of getName that
requests the symbol name.
|
String |
getSymbol(Locale loc)
Convenience and compatibility override of getName that
requests the symbol name.
|
String |
getSymbol(ULocale uloc)
Convenience and compatibility override of getName that
requests the symbol name.
|
int |
hashCode()
Return a hashcode for this currency.
|
static String |
parse(ULocale locale,
String text,
ParsePosition pos)
Deprecated.
This API is ICU internal only.
|
static Object |
registerInstance(Currency currency,
ULocale locale)
Registers a new currency for the provided locale.
|
String |
toString()
Returns the ISO 4217 code for this currency.
|
static boolean |
unregister(Object registryKey)
Unregister the currency associated with this key (obtained from
registerInstance).
|
public static final int SYMBOL_NAME
public static final int LONG_NAME
protected Currency(String theISOCode)
theISOCode - The iso code used to construct the currency.public static Currency getInstance(Locale locale)
locale - the localepublic static Currency getInstance(ULocale locale)
public static Currency getInstance(String theISOCode)
theISOCode - the iso codepublic static Object registerInstance(Currency currency, ULocale locale)
currency - the currency to registerlocale - the ulocale under which to register the currencyunregister(java.lang.Object)public static boolean unregister(Object registryKey)
registryKey - the registry key returned from registerInstanceregisterInstance(com.ibm.icu.util.Currency, com.ibm.icu.util.ULocale)public static Locale[] getAvailableLocales()
public static ULocale[] getAvailableULocales()
public int hashCode()
public boolean equals(Object rhs)
public String getCurrencyCode()
public String getSymbol()
getName(java.util.Locale, int, boolean[])public String getSymbol(Locale loc)
loc - the Locale for the symbolgetName(java.util.Locale, int, boolean[])public String getSymbol(ULocale uloc)
uloc - the ULocale for the symbolgetName(java.util.Locale, int, boolean[])public String getName(Locale locale, int nameStyle, boolean[] isChoiceFormat)
locale - locale in which to display currencynameStyle - selector for which kind of name to returnisChoiceFormat - fill-in; isChoiceFormat[0] is set to true
if the returned value is a ChoiceFormat pattern; otherwise it
is set to falsepublic String getName(ULocale locale, int nameStyle, boolean[] isChoiceFormat)
locale - locale in which to display currencynameStyle - selector for which kind of name to returnisChoiceFormat - fill-in; isChoiceFormat[0] is set to true
if the returned value is a ChoiceFormat pattern; otherwise it
is set to falsepublic static String parse(ULocale locale, String text, ParsePosition pos)
locale - the locale of the display names to matchtext - the text to parsepos - input-output position; on input, the position within
text to match; must have 0 <= pos.getIndex() < text.length();
on output, the position after the last matched character. If
the parse fails, the position in unchanged upon output.public int getDefaultFractionDigits()
public double getRoundingIncrement()
public String toString()
public final ULocale getLocale(ULocale.Type type)
Note: This method will be obsoleted. The implementation is no longer locale-specific and so there is no longer a valid or actual locale associated with the Currency object. Until it is removed, this method will return the root locale.
type - type of information requested, either ULocale.VALID_LOCALE or ULocale.ACTUAL_LOCALE.ULocale,
ULocale.VALID_LOCALE,
ULocale.ACTUAL_LOCALECopyright (c) 2007 IBM Corporation and others.