|
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
java.text.DecimalFormat
public class DecimalFormat
DecimalFormat is used to format and parse numbers, both integers and fractions, based on a pattern. The pattern characters used can be either localized or non-localized.
| 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 new DecimalFormat for formatting and parsing numbers for the default Locale. |
|
DecimalFormat(String pattern)
Constructs a new DecimalFormat using the specified non-localized pattern and the DecimalFormatSymbols for the default Locale. |
|
DecimalFormat(String pattern,
DecimalFormatSymbols value)
Constructs a new DecimalFormat using the specified non-localized pattern and DecimalFormatSymbols. |
|
| Method Summary | |
|---|---|
void |
applyLocalizedPattern(String pattern)
Changes the pattern of this DecimalFormat to the specified pattern which uses localized pattern characters. |
void |
applyPattern(String pattern)
Changes the pattern of this SimpleDateFormat to the specified pattern which uses non-localized pattern characters. |
Object |
clone()
Answers a new instance of DecimalFormat with the same pattern and properties as this DecimalFormat. |
boolean |
equals(Object object)
Compares the specified object to this DecimalFormat and answer if they are equal. |
StringBuffer |
format(double value,
StringBuffer buffer,
FieldPosition position)
Formats the double value into the specified StringBuffer using the pattern of this DecimalFormat. |
StringBuffer |
format(long value,
StringBuffer buffer,
FieldPosition position)
Formats the long value into the specified StringBuffer using the pattern of this DecimalFormat. |
AttributedCharacterIterator |
formatToCharacterIterator(Object object)
Formats the specified object using the rules of this DecimalNumberFormat and returns an AttributedCharacterIterator with the formatted number and attributes. |
Currency |
getCurrency()
Answers the currency used by this decimal format. |
DecimalFormatSymbols |
getDecimalFormatSymbols()
Answers the DecimalFormatSymbols used by this DecimalFormat. |
int |
getGroupingSize()
Answers the number of digits grouped together by the grouping separator. |
int |
getMultiplier()
Answers the multiplier which is applied to the number before formatting or after parsing. |
String |
getNegativePrefix()
Answers the prefix which is formatted or parsed before a negative number. |
String |
getNegativeSuffix()
Answers the suffix which is formatted or parsed after a negative number. |
String |
getPositivePrefix()
Answers the prefix which is formatted or parsed before a positive number. |
String |
getPositiveSuffix()
Answers the suffix which is formatted or parsed after a positive number. |
int |
hashCode()
Answers an integer hash code for the receiver. |
boolean |
isDecimalSeparatorAlwaysShown()
Answers whether the decimal separator is shown when there are no fractional digits. |
Number |
parse(String string,
ParsePosition position)
Parse a Long or Double from the specified String starting at the index specified by the ParsePosition. |
void |
setCurrency(Currency currency)
Sets the currency used by this decimal format. |
void |
setDecimalFormatSymbols(DecimalFormatSymbols value)
Sets the DecimalFormatSymbols used by this DecimalFormat. |
void |
setDecimalSeparatorAlwaysShown(boolean value)
Sets whether the decimal separator is shown when there are no fractional digits. |
void |
setGroupingSize(int value)
Sets the number of digits grouped together by the 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 |
setMultiplier(int value)
Sets the multiplier which is applied to the number before formatting or after parsing. |
void |
setNegativePrefix(String value)
Sets the prefix which is formatted or parsed before a negative number. |
void |
setNegativeSuffix(String value)
Sets the suffix which is formatted or parsed after a negative number. |
void |
setPositivePrefix(String value)
Sets the prefix which is formatted or parsed before a positive number. |
void |
setPositiveSuffix(String value)
Sets the suffix which is formatted or parsed after a positive number. |
String |
toLocalizedPattern()
Answers the pattern of this DecimalFormat using localized pattern characters. |
String |
toPattern()
Answers the pattern of this DecimalFormat using non-localized pattern characters. |
| 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()
public DecimalFormat(String pattern)
pattern - the non-localized pattern
IllegalArgumentException - when the pattern cannot be parsedpublic DecimalFormat(String pattern,
DecimalFormatSymbols value)
pattern - the non-localized patternvalue - the DecimalFormatSymbols
IllegalArgumentException - when the pattern cannot be parsed| Method Detail |
|---|
public void applyLocalizedPattern(String pattern)
pattern - the localized pattern
IllegalArgumentException - when the pattern cannot be parsedpublic void applyPattern(String pattern)
pattern - the non-localized pattern
IllegalArgumentException - when the pattern cannot be parsedpublic Object clone()
clone in class NumberFormatCloneablepublic boolean equals(Object object)
equals in class NumberFormatobject - the object to compare with this object
hashCode()public AttributedCharacterIterator formatToCharacterIterator(Object object)
formatToCharacterIterator in class Formatobject - the object to format
IllegalArgumentException - when the object cannot be formatted by this Formatpublic StringBuffer format(double value,
StringBuffer buffer,
FieldPosition position)
format in class NumberFormatvalue - the double to formatbuffer - the StringBufferposition - the FieldPosition
bufferpublic StringBuffer format(long value,
StringBuffer buffer,
FieldPosition position)
format in class NumberFormatvalue - the long to formatbuffer - the StringBufferposition - the FieldPosition
bufferpublic DecimalFormatSymbols getDecimalFormatSymbols()
public Currency getCurrency()
getCurrency in class NumberFormatDecimalFormatSymbols.getCurrency()public int getGroupingSize()
public int getMultiplier()
public String getNegativePrefix()
public String getNegativeSuffix()
public String getPositivePrefix()
public String getPositiveSuffix()
public int hashCode()
hashCode in class NumberFormatequals(java.lang.Object)public boolean isDecimalSeparatorAlwaysShown()
public Number parse(String string,
ParsePosition position)
parse in class NumberFormatstring - 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 setDecimalFormatSymbols(DecimalFormatSymbols value)
value - the DecimalFormatSymbolspublic void setCurrency(Currency currency)
setCurrency in class NumberFormatcurrency - DecimalFormatSymbols.setCurrency(Currency)public void setDecimalSeparatorAlwaysShown(boolean value)
value - true if the decimal separator should always be formatted, false otherwisepublic void setGroupingSize(int value)
value - the number of digits grouped togetherpublic void setMaximumFractionDigits(int value)
setMaximumFractionDigits in class NumberFormatvalue - the maximum number of fraction digitspublic void setMaximumIntegerDigits(int value)
setMaximumIntegerDigits in class NumberFormatvalue - the maximum number of integer digitspublic void setMinimumFractionDigits(int value)
setMinimumFractionDigits in class NumberFormatvalue - the minimum number of fraction digitspublic void setMinimumIntegerDigits(int value)
setMinimumIntegerDigits in class NumberFormatvalue - the minimum number of integer digitspublic void setMultiplier(int value)
value - the multiplierpublic void setNegativePrefix(String value)
value - the negative prefixpublic void setNegativeSuffix(String value)
value - the negative suffixpublic void setPositivePrefix(String value)
value - the positive prefixpublic void setPositiveSuffix(String value)
value - the positive suffixpublic String toLocalizedPattern()
public String toPattern()
|
Final | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||