|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.ibm.icu.util.MeasureUnit
com.ibm.icu.util.Currency
public class Currency
A class encapsulating a currency, as defined by ISO 4217. A Currency object can be created given a Locale or given an ISO 4217 code. Once created, the Currency object can return various data necessary to its proper display:
Note: This class deliberately resembles java.util.Currency but it has a completely independent implementation, and adds features not present in the JDK.
Field Summary | |
---|---|
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. |
Constructor Summary | |
---|---|
protected |
Currency(String theISOCode)
Constructs a currency object for the given ISO 4217 3-letter code. |
Method Summary | |
---|---|
boolean |
equals(Object rhs)
Return true if rhs is a Currency instance, is non-null, and has the same currency code. |
static String[] |
getAvailableCurrencyCodes(ULocale loc,
Date d)
Returns an array of Strings which contain the currency identifiers which are valid for the given locale on the given date. |
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). |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final int SYMBOL_NAME
public static final int LONG_NAME
Constructor Detail |
---|
protected Currency(String theISOCode)
theISOCode
- The iso code used to construct the currency.Method Detail |
---|
public static Currency getInstance(Locale locale)
locale
- the locale
public static Currency getInstance(ULocale locale)
public static String[] getAvailableCurrencyCodes(ULocale loc, Date d)
loc
- the locale for which to retrieve currency codes.d
- the date for which to retrieve currency codes for the given locale.
public static Currency getInstance(String theISOCode)
theISOCode
- the iso code
NullPoninterException
- if theISOCode
is null.
IllegalArgumentException
- if theISOCode
is not a
3-letter alpha code.public static Object registerInstance(Currency currency, ULocale locale)
currency
- the currency to registerlocale
- the ulocale under which to register the currency
unregister(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()
hashCode
in class Object
public boolean equals(Object rhs)
equals
in class Object
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 false
public 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 false
public 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()
toString
in class Object
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_LOCALE
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |