|
Build 1.0_r1(from source) | |||||||||
| 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()
Returns 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. |
StringBuffer |
format(Object number,
StringBuffer toAppendTo,
FieldPosition pos)
Formats the number 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()
Returns the currency used by this decimal format. |
DecimalFormatSymbols |
getDecimalFormatSymbols()
Returns the DecimalFormatSymbols used by this DecimalFormat. |
int |
getGroupingSize()
Returns the number of digits grouped together by the grouping separator. |
int |
getMultiplier()
Returns the multiplier which is applied to the number before formatting or after parsing. |
String |
getNegativePrefix()
Returns the prefix which is formatted or parsed before a negative number. |
String |
getNegativeSuffix()
Returns the suffix which is formatted or parsed after a negative number. |
String |
getPositivePrefix()
Returns the prefix which is formatted or parsed before a positive number. |
String |
getPositiveSuffix()
Returns the suffix which is formatted or parsed after a positive number. |
int |
hashCode()
Returns an integer hash code for the receiver. |
boolean |
isDecimalSeparatorAlwaysShown()
Returns whether the decimal separator is shown when there are no fractional digits. |
boolean |
isGroupingUsed()
This value indicates whether grouping will be used in this format. |
boolean |
isParseBigDecimal()
This value indicates whether the return object of the parse operation will be of type BigDecimal. |
boolean |
isParseIntegerOnly()
Returns true if this DecimalFormat's all resulting number
will be of type java.lang.Integer |
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 |
setGroupingUsed(boolean value)
Sets whether or not grouping will be used in this format. |
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 |
setParseBigDecimal(boolean newValue)
Let users change the behavior of a DecimalFormat, If set to true all the returned objects will be of type BigDecimal |
void |
setParseIntegerOnly(boolean value)
When DecimalFormat is used to parsing, and this value is set to true, then all the resulting number will be of type java.lang.Integer. |
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()
Returns the pattern of this DecimalFormat using localized pattern characters. |
String |
toPattern()
Returns the pattern of this DecimalFormat using non-localized pattern characters. |
| Methods inherited from class java.text.Format |
|---|
convertPattern, format, getBundle, parseObject, upTo, upToWithQuotes |
| 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 parsed
public 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
NullPointerException - when the object is null
IllegalArgumentException - when the object cannot be formatted by this Format
public StringBuffer format(double value,
StringBuffer buffer,
FieldPosition position)
format in class NumberFormatvalue - the double to formatbuffer - the StringBufferposition - the FieldPosition
buffer
public StringBuffer format(long value,
StringBuffer buffer,
FieldPosition position)
format in class NumberFormatvalue - the long to formatbuffer - the StringBufferposition - the FieldPosition
buffer
public final StringBuffer format(Object number,
StringBuffer toAppendTo,
FieldPosition pos)
format in class NumberFormatnumber - the object to formattoAppendTo - the StringBufferpos - the FieldPosition
buffer
IllegalArgumentException - if the given number is not instance of Numberpublic 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 boolean isParseBigDecimal()
public void setParseIntegerOnly(boolean value)
java.lang.Integer. Except that, NaN, positive and
negative infinity are still returned as java.lang.Double
In this implementation, com.ibm.icu4jni.text.DecimalFormat is wrapped to
fulfill most of the format and parse feature. And this method is
delegated to the wrapped instance of com.ibm.icu4jni.text.DecimalFormat.
setParseIntegerOnly in class NumberFormatvalue - If set to true, all the resulting number will be of type
java.lang.Integer except some special cases.public boolean isParseIntegerOnly()
DecimalFormat's all resulting number
will be of type java.lang.Integer
isParseIntegerOnly in class NumberFormatDecimalFormat's all resulting number
will be of type java.lang.Integer
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 setGroupingUsed(boolean value)
setGroupingUsed in class NumberFormatvalue - true if uses grouping,false otherwise.public boolean isGroupingUsed()
isGroupingUsed in class NumberFormatpublic 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 void setParseBigDecimal(boolean newValue)
newValue - true if all the returned objects should be type of BigDecimalpublic String toLocalizedPattern()
public String toPattern()
|
Build 1.0_r1(from source) | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||