|
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.text.Format
java.text.NumberFormat
java.text.DecimalFormat
public class DecimalFormat
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class java.text.NumberFormat |
|---|
NumberFormat.Field |
| Field Summary |
|---|
| Fields inherited from class java.text.NumberFormat |
|---|
FRACTION_FIELD, INTEGER_FIELD |
| Constructor Summary | |
|---|---|
DecimalFormat()
Constructs a DecimalFormat which uses the default
pattern and symbols. |
|
DecimalFormat(String pattern)
Constructs a DecimalFormat which uses the given
pattern and the default symbols for formatting and parsing. |
|
DecimalFormat(String pattern,
DecimalFormatSymbols symbols)
Constructs a DecimalFormat using the given pattern
and formatting symbols. |
|
| Method Summary | |
|---|---|
void |
applyLocalizedPattern(String pattern)
|
void |
applyPattern(String pattern)
|
Object |
clone()
Creates a copy of this object. |
boolean |
equals(Object obj)
Tests this instance for equality with an arbitrary object. |
StringBuffer |
format(double number,
StringBuffer dest,
FieldPosition fieldPos)
This method formats the specified double and appends it to
a StringBuffer. |
StringBuffer |
format(long number,
StringBuffer dest,
FieldPosition fieldPos)
This method formats the specified long and appends it to
a StringBuffer. |
AttributedCharacterIterator |
formatToCharacterIterator(Object value)
|
Currency |
getCurrency()
Returns the currency corresponding to the currency symbol stored in the instance of DecimalFormatSymbols used by this
DecimalFormat. |
DecimalFormatSymbols |
getDecimalFormatSymbols()
Returns a copy of the symbols used by this instance. |
int |
getGroupingSize()
|
int |
getMultiplier()
|
String |
getNegativePrefix()
|
String |
getNegativeSuffix()
|
String |
getPositivePrefix()
|
String |
getPositiveSuffix()
|
int |
hashCode()
Returns a hash code for this object. |
boolean |
isDecimalSeparatorAlwaysShown()
|
Number |
parse(String str,
ParsePosition pos)
This method parses the specified string into a Number. |
void |
setCurrency(Currency currency)
Sets the Currency on the
DecimalFormatSymbols used, which also sets the
currency symbols on those symbols. |
void |
setDecimalFormatSymbols(DecimalFormatSymbols newSymbols)
Sets the symbols used by this instance. |
void |
setDecimalSeparatorAlwaysShown(boolean newValue)
|
void |
setGroupingSize(int groupSize)
|
void |
setMaximumFractionDigits(int newValue)
This method sets the maximum number of digits allowed in the fraction portion of a number to the specified value. |
void |
setMaximumIntegerDigits(int newValue)
This method sets the maximum number of digits allowed in the integer portion of a number to the specified value. |
void |
setMinimumFractionDigits(int newValue)
This method sets the minimum number of digits allowed in the fraction portion of a number to the specified value. |
void |
setMinimumIntegerDigits(int newValue)
This method sets the minimum number of digits allowed in the integer portion of a number to the specified value. |
void |
setMultiplier(int newValue)
|
void |
setNegativePrefix(String newValue)
|
void |
setNegativeSuffix(String newValue)
|
void |
setPositivePrefix(String newValue)
|
void |
setPositiveSuffix(String newValue)
|
String |
toLocalizedPattern()
|
String |
toPattern()
|
| Methods inherited from class java.text.Format |
|---|
format, parseObject |
| Methods inherited from class java.lang.Object |
|---|
finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public DecimalFormat()
DecimalFormat which uses the default
pattern and symbols.
public DecimalFormat(String pattern)
DecimalFormat which uses the given
pattern and the default symbols for formatting and parsing.
pattern - the non-localized pattern to use.
NullPointerException - if any argument is null.
IllegalArgumentException - if the pattern is invalid.
public DecimalFormat(String pattern,
DecimalFormatSymbols symbols)
DecimalFormat using the given pattern
and formatting symbols. This construction method is used to give
complete control over the formatting process.
pattern - the non-localized pattern to use.symbols - the set of symbols used for parsing and formatting.
NullPointerException - if any argument is null.
IllegalArgumentException - if the pattern is invalid.| Method Detail |
|---|
public void applyLocalizedPattern(String pattern)
public void applyPattern(String pattern)
public Object clone()
Format
clone in class FormatObject.public boolean equals(Object obj)
true if:
obj is not null;obj is an instance of DecimalFormat;obj have the same attributes;
equals in class NumberFormatobj - the object (null permitted).
public StringBuffer format(double number,
StringBuffer dest,
FieldPosition fieldPos)
NumberFormatdouble and appends it to
a StringBuffer.
format in class NumberFormatnumber - The double to format.dest - The StringBuffer to append the formatted number
to.fieldPos - The desired FieldPosition.
StringBuffer with the appended number.public AttributedCharacterIterator formatToCharacterIterator(Object value)
formatToCharacterIterator in class Format
public StringBuffer format(long number,
StringBuffer dest,
FieldPosition fieldPos)
NumberFormatlong and appends it to
a StringBuffer.
format in class NumberFormatnumber - The long to format.dest - The StringBuffer to append the formatted number
to.fieldPos - The desired FieldPosition.
StringBuffer with the appended number.public Currency getCurrency()
DecimalFormatSymbols used by this
DecimalFormat.
getCurrency in class NumberFormatCurrency if
the currency code matches a known one, null otherwise.public DecimalFormatSymbols getDecimalFormatSymbols()
public int getGroupingSize()
public int getMultiplier()
public String getNegativePrefix()
public String getNegativeSuffix()
public String getPositivePrefix()
public String getPositiveSuffix()
public int hashCode()
hashCode in class NumberFormatpublic boolean isDecimalSeparatorAlwaysShown()
public Number parse(String str,
ParsePosition pos)
NumberFormatNumber. This
will be a Long if possible, otherwise it will be a
Double. If no number can be parsed, no exception is
thrown. Instead, the parse position remains at its initial index.
parse in class NumberFormatstr - The string to parse.pos - The desired ParsePosition.
Numberpublic void setCurrency(Currency currency)
Currency on the
DecimalFormatSymbols used, which also sets the
currency symbols on those symbols.
setCurrency in class NumberFormatcurrency - The new currency to be used by this number format.public void setDecimalFormatSymbols(DecimalFormatSymbols newSymbols)
newSymbols - the symbols (null not permitted).public void setDecimalSeparatorAlwaysShown(boolean newValue)
public void setGroupingSize(int groupSize)
public void setMaximumFractionDigits(int newValue)
NumberFormat
setMaximumFractionDigits in class NumberFormatnewValue - The new maximum fraction digits value.public void setMaximumIntegerDigits(int newValue)
NumberFormat
setMaximumIntegerDigits in class NumberFormatnewValue - The new maximum integer digits value.public void setMinimumFractionDigits(int newValue)
NumberFormat
setMinimumFractionDigits in class NumberFormatnewValue - The new minimum fraction digits value.public void setMinimumIntegerDigits(int newValue)
NumberFormat
setMinimumIntegerDigits in class NumberFormatnewValue - The new minimum integer digits value.public void setMultiplier(int newValue)
public void setNegativePrefix(String newValue)
public void setNegativeSuffix(String newValue)
public void setPositivePrefix(String newValue)
public void setPositiveSuffix(String newValue)
public String toLocalizedPattern()
public String toPattern()
|
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||