|
|||||||||
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 |
PLURAL_LONG_NAME
Selector for getName() indicating the plural long name for a currency, such as "US dollar" for USD in "1 US dollar", and "US dollars" for USD in "2 US dollars". |
static int |
SYMBOL_NAME
Selector for getName() indicating a symbolic name for a currency, such as "$" for USD. |
Constructor Summary | |
---|---|
protected |
Currency(java.lang.String theISOCode)
Constructs a currency object for the given ISO 4217 3-letter code. |
Method Summary | |
---|---|
boolean |
equals(java.lang.Object rhs)
Return true if rhs is a Currency instance, is non-null, and has the same currency code. |
static java.lang.String[] |
getAvailableCurrencyCodes(ULocale loc,
java.util.Date d)
Returns an array of Strings which contain the currency identifiers that are valid for the given locale on the given date. |
static java.util.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. |
java.lang.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(java.util.Locale locale)
Returns a currency object for the default currency in the given locale. |
static Currency |
getInstance(java.lang.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. |
static java.lang.String[] |
getKeywordValuesForLocale(java.lang.String key,
ULocale locale,
boolean commonlyUsed)
Given a key and a locale, returns an array of values for the key for which data exists. |
ULocale |
getLocale(ULocale.Type type)
Deprecated. This API is obsolete. |
java.lang.String |
getName(java.util.Locale locale,
int nameStyle,
boolean[] isChoiceFormat)
Returns the display name for the given currency in the given locale. |
java.lang.String |
getName(java.util.Locale locale,
int nameStyle,
java.lang.String pluralCount,
boolean[] isChoiceFormat)
Returns the display name for the given currency in the given locale. |
java.lang.String |
getName(ULocale locale,
int nameStyle,
boolean[] isChoiceFormat)
Returns the display name for the given currency in the given locale. |
java.lang.String |
getName(ULocale locale,
int nameStyle,
java.lang.String pluralCount,
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. |
java.lang.String |
getSymbol()
Convenience and compatibility override of getName that requests the symbol name. |
java.lang.String |
getSymbol(java.util.Locale loc)
Convenience and compatibility override of getName that requests the symbol name. |
java.lang.String |
getSymbol(ULocale uloc)
Convenience and compatibility override of getName that requests the symbol name. |
int |
hashCode()
Return a hashcode for this currency. |
static java.lang.String |
parse(ULocale locale,
java.lang.String text,
int type,
java.text.ParsePosition pos)
Deprecated. This API is ICU internal only. |
static java.lang.Object |
registerInstance(Currency currency,
ULocale locale)
Registers a new currency for the provided locale. |
java.lang.String |
toString()
Returns the ISO 4217 code for this currency. |
static boolean |
unregister(java.lang.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
public static final int PLURAL_LONG_NAME
Constructor Detail |
---|
protected Currency(java.lang.String theISOCode)
theISOCode
- The iso code used to construct the currency.Method Detail |
---|
public static Currency getInstance(java.util.Locale locale)
locale
- the locale
public static Currency getInstance(ULocale locale)
public static java.lang.String[] getAvailableCurrencyCodes(ULocale loc, java.util.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(java.lang.String theISOCode)
theISOCode
- the iso code
java.lang.NullPointerException
- if theISOCode
is null.
java.lang.IllegalArgumentException
- if theISOCode
is not a
3-letter alpha code.public static java.lang.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(java.lang.Object registryKey)
registryKey
- the registry key returned from registerInstanceregisterInstance(com.ibm.icu.util.Currency, com.ibm.icu.util.ULocale)
public static java.util.Locale[] getAvailableLocales()
public static ULocale[] getAvailableULocales()
public static final java.lang.String[] getKeywordValuesForLocale(java.lang.String key, ULocale locale, boolean commonlyUsed)
The only supported key is "currency", other values return an empty array.
Currency information is based on the region of the locale. If the locale does not
indicate a region, ULocale.addLikelySubtags(ULocale)
is used to infer a region,
except for the 'und' locale.
If commonlyUsed is true, only the currencies known to be in use as of the current date are returned. When there are more than one, these are returned in preference order (typically, this occurs when a country is transitioning to a new currency, and the newer currency is preferred), see Unicode TR#35 Sec. C1. If commonlyUsed is false, all currencies ever used in any locale are returned, in no particular order.
key
- key whose values to look up. the only recognized key is "currency"locale
- the localecommonlyUsed
- if true, return only values that are currently used in the locale.
Otherwise returns all values.
public int hashCode()
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object rhs)
equals
in class java.lang.Object
public java.lang.String getCurrencyCode()
public java.lang.String getSymbol()
getName(java.util.Locale, int, boolean[])
public java.lang.String getSymbol(java.util.Locale loc)
loc
- the Locale for the symbolgetName(java.util.Locale, int, boolean[])
public java.lang.String getSymbol(ULocale uloc)
uloc
- the ULocale for the symbolgetName(java.util.Locale, int, boolean[])
public java.lang.String getName(java.util.Locale locale, int nameStyle, boolean[] isChoiceFormat)
public java.lang.String getName(ULocale locale, int nameStyle, boolean[] isChoiceFormat)
locale
- locale in which to display currencynameStyle
- selector for which kind of name to return.
The nameStyle should be either SYMBOL_NAME or
LONG_NAME. Otherwise, throw IllegalArgumentException.isChoiceFormat
- fill-in; isChoiceFormat[0] is set to true
if the returned value is a ChoiceFormat pattern; otherwise it
is set to false
java.lang.IllegalArgumentException
- if the nameStyle is not SYMBOL_NAME
or LONG_NAME.getName(ULocale, int, String, boolean[])
public java.lang.String getName(java.util.Locale locale, int nameStyle, java.lang.String pluralCount, boolean[] isChoiceFormat)
public java.lang.String getName(ULocale locale, int nameStyle, java.lang.String pluralCount, boolean[] isChoiceFormat)
locale
- locale in which to display currencynameStyle
- selector for which kind of name to returnpluralCount
- plural count string for this localeisChoiceFormat
- fill-in; isChoiceFormat[0] is set to true
if the returned value is a ChoiceFormat pattern; otherwise it
is set to false
java.lang.IllegalArgumentException
- if the nameStyle is not SYMBOL_NAME,
LONG_NAME, or PLURAL_LONG_NAME.public static java.lang.String parse(ULocale locale, java.lang.String text, int type, java.text.ParsePosition pos)
locale
- the locale of the display names to matchtext
- the text to parsetype
- parse against currency type: LONG_NAME only or notpos
- 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 java.lang.String toString()
toString
in class java.lang.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 |