|
Final | |||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Objectjava.text.Format
java.text.NumberFormat
public abstract class NumberFormat
NumberFormat is the abstract superclass of Formats which format and parse Numbers.
| Nested Class Summary | |
|---|---|
static class |
NumberFormat.Field
The instances of this inner class are used as attribute keys and values in AttributedCharacterIterator that NumberFormat.formatToCharacterIterator() method returns. |
| Field Summary | |
|---|---|
static int |
FRACTION_FIELD
Field constant. |
static int |
INTEGER_FIELD
Field constant. |
| Constructor Summary | |
|---|---|
NumberFormat()
Constructs a new instance of DateFormat. |
|
| Method Summary | |
|---|---|
Object |
clone()
Answers a new NumberFormat with the same properties as this NumberFormat. |
boolean |
equals(Object object)
Compares the specified object to this NumberFormat and answer if they are equal. |
String |
format(double value)
Formats the specified double using the rules of this NumberFormat. |
abstract StringBuffer |
format(double value,
StringBuffer buffer,
FieldPosition field)
Formats the double value into the specified StringBuffer using the rules of this NumberFormat. |
String |
format(long value)
Formats the specified long using the rules of this NumberFormat. |
abstract StringBuffer |
format(long value,
StringBuffer buffer,
FieldPosition field)
Formats the long value into the specified StringBuffer using the rules of this NumberFormat. |
StringBuffer |
format(Object object,
StringBuffer buffer,
FieldPosition field)
Formats the specified object into the specified StringBuffer using the rules of this DateFormat. |
static Locale[] |
getAvailableLocales()
Gets the list of installed Locales which support NumberFormat. |
Currency |
getCurrency()
Answers the currency used by this number format |
static NumberFormat |
getCurrencyInstance()
Answers a NumberFormat for formatting and parsing currency for the default Locale. |
static NumberFormat |
getCurrencyInstance(Locale locale)
Answers a NumberFormat for formatting and parsing currency for the specified Locale. |
static NumberFormat |
getInstance()
Answers a NumberFormat for formatting and parsing numbers for the default Locale. |
static NumberFormat |
getInstance(Locale locale)
Answers a NumberFormat for formatting and parsing numbers for the specified Locale. |
static NumberFormat |
getIntegerInstance()
Answers a NumberFormat for formatting and parsing integers for the default Locale. |
static NumberFormat |
getIntegerInstance(Locale locale)
Answers a NumberFormat for formatting and parsing integers for the specified Locale. |
int |
getMaximumFractionDigits()
Answers the maximum number of fraction digits that are printed when formatting. |
int |
getMaximumIntegerDigits()
Answers the maximum number of integer digits that are printed when formatting. |
int |
getMinimumFractionDigits()
Answers the minimum number of fraction digits that are printed when formatting. |
int |
getMinimumIntegerDigits()
Answers the minimum number of integer digits that are printed when formatting. |
static NumberFormat |
getNumberInstance()
Answers a NumberFormat for formatting and parsing numbers for the default Locale. |
static NumberFormat |
getNumberInstance(Locale locale)
Answers a NumberFormat for formatting and parsing numbers for the specified Locale. |
static NumberFormat |
getPercentInstance()
Answers a NumberFormat for formatting and parsing percentages for the default Locale. |
static NumberFormat |
getPercentInstance(Locale locale)
Answers a NumberFormat for formatting and parsing percentages for the specified Locale. |
int |
hashCode()
Answers an integer hash code for the receiver. |
boolean |
isGroupingUsed()
Answers whether this NumberFormat formats and parses numbers using a grouping separator. |
boolean |
isParseIntegerOnly()
Answers whether this NumberFormat only parses integer numbers. |
Number |
parse(String string)
Parse a Number from the specified String using the rules of this NumberFormat. |
abstract Number |
parse(String string,
ParsePosition position)
Parse a Number from the specified String starting at the index specified by the ParsePosition. |
Object |
parseObject(String string,
ParsePosition position)
Parse a Number from the specified String starting at the index specified by the ParsePosition. |
void |
setCurrency(Currency currency)
Sets the currency used by this number format when formatting currency values. |
void |
setGroupingUsed(boolean value)
Sets whether this NumberFormat formats and parses numbers using a grouping separator. |
void |
setMaximumFractionDigits(int value)
Sets the maximum number of fraction digits that are printed when formatting. |
void |
setMaximumIntegerDigits(int value)
Sets the maximum number of integer digits that are printed when formatting. |
void |
setMinimumFractionDigits(int value)
Sets the minimum number of fraction digits that are printed when formatting. |
void |
setMinimumIntegerDigits(int value)
Sets the minimum number of integer digits that are printed when formatting. |
void |
setParseIntegerOnly(boolean value)
Sets whether this NumberFormat only parses integer numbers. |
| Methods inherited from class java.text.Format |
|---|
format, formatToCharacterIterator, parseObject |
| Methods inherited from class java.lang.Object |
|---|
finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final int INTEGER_FIELD
public static final int FRACTION_FIELD
| Constructor Detail |
|---|
public NumberFormat()
| Method Detail |
|---|
public Object clone()
clone in class FormatCloneablepublic boolean equals(Object object)
equals in class Objectobject - the object to compare with this object
hashCode()public final String format(double value)
value - the double to format
public abstract StringBuffer format(double value,
StringBuffer buffer,
FieldPosition field)
value - the double to formatbuffer - the StringBufferfield - the FieldPosition
bufferpublic final String format(long value)
value - the long to format
public abstract StringBuffer format(long value,
StringBuffer buffer,
FieldPosition field)
value - the long to formatbuffer - the StringBufferfield - the FieldPosition
bufferpublic StringBuffer format(Object object,
StringBuffer buffer,
FieldPosition field)
format in class Formatobject - the object to format, must be a Numberbuffer - the StringBufferfield - the FieldPosition
buffer
IllegalArgumentException - when the object is not a Numberpublic static Locale[] getAvailableLocales()
public Currency getCurrency()
This implementation throws UnsupportedOperationException, concrete sub classes should override if they support currency formatting.
UnsupportedOperationExceptionpublic static final NumberFormat getCurrencyInstance()
public static NumberFormat getCurrencyInstance(Locale locale)
locale - the Locale
public static final NumberFormat getIntegerInstance()
public static NumberFormat getIntegerInstance(Locale locale)
locale - the Locale
public static final NumberFormat getInstance()
public static NumberFormat getInstance(Locale locale)
locale - the Locale
public int getMaximumFractionDigits()
public int getMaximumIntegerDigits()
public int getMinimumFractionDigits()
public int getMinimumIntegerDigits()
public static final NumberFormat getNumberInstance()
public static NumberFormat getNumberInstance(Locale locale)
locale - the Locale
public static final NumberFormat getPercentInstance()
public static NumberFormat getPercentInstance(Locale locale)
locale - the Locale
public int hashCode()
hashCode in class Objectequals(java.lang.Object)public boolean isGroupingUsed()
public boolean isParseIntegerOnly()
public Number parse(String string)
throws ParseException
string - the String to parse
ParseException - when an error occurs during parsingpublic abstract Number parse(String string,
ParsePosition position)
string - the String to parseposition - the ParsePosition, updated on return with the index following
the parsed text, or on error the index is unchanged and the
error index is set to the index where the error occurred
public final Object parseObject(String string,
ParsePosition position)
parseObject in class Formatstring - the String to parseposition - the ParsePosition, updated on return with the index following
the parsed text, or on error the index is unchanged and the
error index is set to the index where the error occurred
public void setCurrency(Currency currency)
The min and max fraction digits remain the same.
This implementation throws UnsupportedOperationException, concrete sub classes should override if they support currency formatting.
currency - the new Currency
UnsupportedOperationExceptionpublic void setGroupingUsed(boolean value)
value - true when a grouping separator is used, false otherwisepublic void setMaximumFractionDigits(int value)
value - the maximum number of fraction digitspublic void setMaximumIntegerDigits(int value)
value - the maximum number of integer digitspublic void setMinimumFractionDigits(int value)
value - the minimum number of fraction digitspublic void setMinimumIntegerDigits(int value)
value - the minimum number of integer digitspublic void setParseIntegerOnly(boolean value)
value - true to only parse integers, false to parse integers or fractions
|
Final | |||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||