| java.lang.Object java.text.Format java.text.NumberFormat java.text.DecimalFormat
DecimalFormat | public class DecimalFormat extends NumberFormat (Code) | | 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.
|
Constructor Summary | |
public | DecimalFormat() Constructs a new DecimalFormat for formatting and parsing numbers for the
default Locale. | public | DecimalFormat(String pattern) Constructs a new DecimalFormat using the specified non-localized pattern
and the DecimalFormatSymbols for the default Locale. | public | DecimalFormat(String pattern, DecimalFormatSymbols value) Constructs a new DecimalFormat using the specified non-localized pattern
and DecimalFormatSymbols. |
Method Summary | |
public void | applyLocalizedPattern(String pattern) Changes the pattern of this DecimalFormat to the specified pattern which
uses localized pattern characters. | public void | applyPattern(String pattern) Changes the pattern of this SimpleDateFormat to the specified pattern
which uses non-localized pattern characters. | public Object | clone() Answers a new instance of DecimalFormat with the same pattern and
properties as this DecimalFormat. | public boolean | equals(Object object) Compares the specified object to this DecimalFormat and answer if they
are equal. | public StringBuffer | format(double value, StringBuffer buffer, FieldPosition position) Formats the double value into the specified StringBuffer using the
pattern of this DecimalFormat. | public StringBuffer | format(long value, StringBuffer buffer, FieldPosition position) Formats the long value into the specified StringBuffer using the pattern
of this DecimalFormat. | final public StringBuffer | format(Object number, StringBuffer toAppendTo, FieldPosition pos) Formats the number into the specified StringBuffer using the pattern of
this DecimalFormat. | public AttributedCharacterIterator | formatToCharacterIterator(Object object) Formats the specified object using the rules of this DecimalNumberFormat
and returns an AttributedCharacterIterator with the formatted number and
attributes. | public Currency | getCurrency() Answers the currency used by this decimal format. | public DecimalFormatSymbols | getDecimalFormatSymbols() Answers the DecimalFormatSymbols used by this DecimalFormat. | public int | getGroupingSize() Answers the number of digits grouped together by the grouping separator. | public int | getMultiplier() Answers the multiplier which is applied to the number before formatting
or after parsing. | public String | getNegativePrefix() Answers the prefix which is formatted or parsed before a negative number. | public String | getNegativeSuffix() Answers the suffix which is formatted or parsed after a negative number. | public String | getPositivePrefix() Answers the prefix which is formatted or parsed before a positive number. | public String | getPositiveSuffix() Answers the suffix which is formatted or parsed after a positive number. | public int | hashCode() Answers an integer hash code for the receiver. | public boolean | isDecimalSeparatorAlwaysShown() Answers whether the decimal separator is shown when there are no
fractional digits. | public boolean | isGroupingUsed() This value indicates whether grouping will be used in this format. | public boolean | isParseBigDecimal() This value indicates whether the return object of the parse operation
will be of type BigDecimal. | public boolean | isParseIntegerOnly() | public Number | parse(String string, ParsePosition position) Parse a Long or Double from the specified String starting at the index
specified by the ParsePosition. | public void | setCurrency(Currency currency) Sets the currency used by this decimal format. | public void | setDecimalFormatSymbols(DecimalFormatSymbols value) Sets the DecimalFormatSymbols used by this DecimalFormat. | public void | setDecimalSeparatorAlwaysShown(boolean value) Sets whether the decimal separator is shown when there are no fractional
digits. | public void | setGroupingSize(int value) Sets the number of digits grouped together by the grouping separator. | public void | setGroupingUsed(boolean value) Sets whether or not grouping will be used in this format. | public void | setMaximumFractionDigits(int value) Sets the maximum number of fraction digits that are printed when
formatting. | public void | setMaximumIntegerDigits(int value) Sets the maximum number of integer digits that are printed when
formatting. | public void | setMinimumFractionDigits(int value) Sets the minimum number of fraction digits that are printed when
formatting. | public void | setMinimumIntegerDigits(int value) Sets the minimum number of integer digits that are printed when
formatting. | public void | setMultiplier(int value) Sets the multiplier which is applied to the number before formatting or
after parsing. | public void | setNegativePrefix(String value) Sets the prefix which is formatted or parsed before a negative number. | public void | setNegativeSuffix(String value) Sets the suffix which is formatted or parsed after a negative number. | public void | setParseBigDecimal(boolean newValue) | public 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 . | public void | setPositivePrefix(String value) Sets the prefix which is formatted or parsed before a positive number. | public void | setPositiveSuffix(String value) Sets the suffix which is formatted or parsed after a positive number. | public String | toLocalizedPattern() Answers the pattern of this DecimalFormat using localized pattern
characters. | public String | toPattern() Answers the pattern of this DecimalFormat using non-localized pattern
characters. |
DecimalFormat | public DecimalFormat()(Code) | | Constructs a new DecimalFormat for formatting and parsing numbers for the
default Locale.
|
DecimalFormat | public DecimalFormat(String pattern)(Code) | | Constructs a new DecimalFormat using the specified non-localized pattern
and the DecimalFormatSymbols for the default Locale.
Parameters: pattern - the non-localized pattern exception: IllegalArgumentException - when the pattern cannot be parsed |
DecimalFormat | public DecimalFormat(String pattern, DecimalFormatSymbols value)(Code) | | Constructs a new DecimalFormat using the specified non-localized pattern
and DecimalFormatSymbols.
Parameters: pattern - the non-localized pattern Parameters: value - the DecimalFormatSymbols exception: IllegalArgumentException - when the pattern cannot be parsed |
applyLocalizedPattern | public void applyLocalizedPattern(String pattern)(Code) | | Changes the pattern of this DecimalFormat to the specified pattern which
uses localized pattern characters.
Parameters: pattern - the localized pattern exception: IllegalArgumentException - when the pattern cannot be parsed |
applyPattern | public void applyPattern(String pattern)(Code) | | Changes the pattern of this SimpleDateFormat to the specified pattern
which uses non-localized pattern characters.
Parameters: pattern - the non-localized pattern exception: IllegalArgumentException - when the pattern cannot be parsed |
clone | public Object clone()(Code) | | Answers a new instance of DecimalFormat with the same pattern and
properties as this DecimalFormat.
a shallow copy of this DecimalFormat See Also: java.lang.Cloneable |
equals | public boolean equals(Object object)(Code) | | Compares the specified object to this DecimalFormat and answer if they
are equal. The object must be an instance of DecimalFormat with the same
pattern and properties.
Parameters: object - the object to compare with this object true if the specified object is equal to this DecimalFormat,false otherwise See Also: DecimalFormat.hashCode |
format | public StringBuffer format(double value, StringBuffer buffer, FieldPosition position)(Code) | | Formats the double value into the specified StringBuffer using the
pattern of this DecimalFormat. If the field specified by the
FieldPosition is formatted, set the begin and end index of the formatted
field in the FieldPosition.
Parameters: value - the double to format Parameters: buffer - the StringBuffer Parameters: position - the FieldPosition the StringBuffer parameter buffer |
format | public StringBuffer format(long value, StringBuffer buffer, FieldPosition position)(Code) | | Formats the long value into the specified StringBuffer using the pattern
of this DecimalFormat. If the field specified by the FieldPosition is
formatted, set the begin and end index of the formatted field in the
FieldPosition.
Parameters: value - the long to format Parameters: buffer - the StringBuffer Parameters: position - the FieldPosition the StringBuffer parameter buffer |
format | final public StringBuffer format(Object number, StringBuffer toAppendTo, FieldPosition pos)(Code) | | Formats the number into the specified StringBuffer using the pattern of
this DecimalFormat. If the field specified by the FieldPosition is
formatted, set the begin and end index of the formatted field in the
FieldPosition.
Parameters: number - the object to format Parameters: toAppendTo - the StringBuffer Parameters: pos - the FieldPosition the StringBuffer parameter buffer throws: IllegalArgumentException - if the given number is not instance of Number |
formatToCharacterIterator | public AttributedCharacterIterator formatToCharacterIterator(Object object)(Code) | | Formats the specified object using the rules of this DecimalNumberFormat
and returns an AttributedCharacterIterator with the formatted number and
attributes.
Parameters: object - the object to format an AttributedCharacterIterator with the formatted number andattributes exception: NullPointerException - when the object is null exception: IllegalArgumentException - when the object cannot be formatted by this Format |
getDecimalFormatSymbols | public DecimalFormatSymbols getDecimalFormatSymbols()(Code) | | Answers the DecimalFormatSymbols used by this DecimalFormat.
a DecimalFormatSymbols |
getGroupingSize | public int getGroupingSize()(Code) | | Answers the number of digits grouped together by the grouping separator.
the number of digits grouped together |
getMultiplier | public int getMultiplier()(Code) | | Answers the multiplier which is applied to the number before formatting
or after parsing.
the multiplier |
getNegativePrefix | public String getNegativePrefix()(Code) | | Answers the prefix which is formatted or parsed before a negative number.
the negative prefix |
getNegativeSuffix | public String getNegativeSuffix()(Code) | | Answers the suffix which is formatted or parsed after a negative number.
the negative suffix |
getPositivePrefix | public String getPositivePrefix()(Code) | | Answers the prefix which is formatted or parsed before a positive number.
the positive prefix |
getPositiveSuffix | public String getPositiveSuffix()(Code) | | Answers the suffix which is formatted or parsed after a positive number.
the positive suffix |
hashCode | public int hashCode()(Code) | | Answers an integer hash code for the receiver. Objects which are equal
answer the same value for this method.
the receiver's hash See Also: DecimalFormat.equals |
isDecimalSeparatorAlwaysShown | public boolean isDecimalSeparatorAlwaysShown()(Code) | | Answers whether the decimal separator is shown when there are no
fractional digits.
true if the decimal separator should always be formatted, falseotherwise |
isGroupingUsed | public boolean isGroupingUsed()(Code) | | This value indicates whether grouping will be used in this format.
true if grouping is used,false otherwise. |
isParseBigDecimal | public boolean isParseBigDecimal()(Code) | | This value indicates whether the return object of the parse operation
will be of type BigDecimal. This value will default to false.
true and parse will always return BigDecimals, false and the typeof the result will be Long or Double. |
isParseIntegerOnly | public boolean isParseIntegerOnly()(Code) | | Returns true if this DecimalFormat 's all resulting number
will be of type java.lang.Integer
true if this DecimalFormat 's all resulting numberwill be of type java.lang.Integer |
parse | public Number parse(String string, ParsePosition position)(Code) | | Parse a Long or Double from the specified String starting at the index
specified by the ParsePosition. If the string is successfully parsed, the
index of the ParsePosition is updated to the index following the parsed
text.
Parameters: string - the String to parse Parameters: position - the ParsePosition, updated on return with the index followingthe parsed text, or on error the index is unchanged and theerror index is set to the index where the error occurred a Long or Double resulting from the parse, or null if there is anerror. The result will be a Long if the parsed number is aninteger in the range of a long, otherwise the result is a Double. |
setDecimalFormatSymbols | public void setDecimalFormatSymbols(DecimalFormatSymbols value)(Code) | | Sets the DecimalFormatSymbols used by this DecimalFormat.
Parameters: value - the DecimalFormatSymbols |
setDecimalSeparatorAlwaysShown | public void setDecimalSeparatorAlwaysShown(boolean value)(Code) | | Sets whether the decimal separator is shown when there are no fractional
digits.
Parameters: value - true if the decimal separator should always be formatted,false otherwise |
setGroupingSize | public void setGroupingSize(int value)(Code) | | Sets the number of digits grouped together by the grouping separator.
Parameters: value - the number of digits grouped together |
setGroupingUsed | public void setGroupingUsed(boolean value)(Code) | | Sets whether or not grouping will be used in this format. Grouping
affects both parsing and formatting.
Parameters: value - true if uses grouping,false otherwise. |
setMaximumFractionDigits | public void setMaximumFractionDigits(int value)(Code) | | Sets the maximum number of fraction digits that are printed when
formatting. If the maximum is less than the number of fraction digits,
the least significant digits are truncated. Limit the maximum to
DOUBLE_FRACTION_DIGITS.
Parameters: value - the maximum number of fraction digits |
setMaximumIntegerDigits | public void setMaximumIntegerDigits(int value)(Code) | | Sets the maximum number of integer digits that are printed when
formatting. If the maximum is less than the number of integer digits, the
most significant digits are truncated. Limit the maximum to
DOUBLE_INTEGER_DIGITS.
Parameters: value - the maximum number of integer digits |
setMinimumFractionDigits | public void setMinimumFractionDigits(int value)(Code) | | Sets the minimum number of fraction digits that are printed when
formatting. Limit the minimum to DOUBLE_FRACTION_DIGITS.
Parameters: value - the minimum number of fraction digits |
setMinimumIntegerDigits | public void setMinimumIntegerDigits(int value)(Code) | | Sets the minimum number of integer digits that are printed when
formatting. Limit the minimum to DOUBLE_INTEGER_DIGITS.
Parameters: value - the minimum number of integer digits |
setMultiplier | public void setMultiplier(int value)(Code) | | Sets the multiplier which is applied to the number before formatting or
after parsing.
Parameters: value - the multiplier |
setNegativePrefix | public void setNegativePrefix(String value)(Code) | | Sets the prefix which is formatted or parsed before a negative number.
Parameters: value - the negative prefix |
setNegativeSuffix | public void setNegativeSuffix(String value)(Code) | | Sets the suffix which is formatted or parsed after a negative number.
Parameters: value - the negative suffix |
setParseBigDecimal | public void setParseBigDecimal(boolean newValue)(Code) | | Let users change the behavior of a DecimalFormat, If set to true all the
returned objects will be of type BigDecimal
Parameters: newValue - true if all the returned objects should be type of BigDecimal |
setParseIntegerOnly | public void setParseIntegerOnly(boolean value)(Code) | | 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 . Except that, NaN, positive and
negative infinity are still returned as java.lang.Double
In this implementation, com.ibm.icu.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.icu.text.DecimalFormat.
Parameters: value - If set to true, all the resulting number will be of typejava.lang.Integer except some special cases. |
setPositivePrefix | public void setPositivePrefix(String value)(Code) | | Sets the prefix which is formatted or parsed before a positive number.
Parameters: value - the positive prefix |
setPositiveSuffix | public void setPositiveSuffix(String value)(Code) | | Sets the suffix which is formatted or parsed after a positive number.
Parameters: value - the positive suffix |
toLocalizedPattern | public String toLocalizedPattern()(Code) | | Answers the pattern of this DecimalFormat using localized pattern
characters.
the localized pattern |
toPattern | public String toPattern()(Code) | | Answers the pattern of this DecimalFormat using non-localized pattern
characters.
the non-localized pattern |
Methods inherited from java.text.Format | public Object clone()(Code)(Java Doc) String convertPattern(String template, String fromChars, String toChars, boolean check)(Code)(Java Doc) final public String format(Object object)(Code)(Java Doc) abstract public StringBuffer format(Object object, StringBuffer buffer, FieldPosition field)(Code)(Java Doc) public AttributedCharacterIterator formatToCharacterIterator(Object object)(Code)(Java Doc) static Object getInternalField(String fieldName, Object target)(Code)(Java Doc) public Object parseObject(String string) throws ParseException(Code)(Java Doc) abstract public Object parseObject(String string, ParsePosition position)(Code)(Java Doc) static boolean upTo(String string, ParsePosition position, StringBuffer buffer, char stop)(Code)(Java Doc) static boolean upToWithQuotes(String string, ParsePosition position, StringBuffer buffer, char stop, char start)(Code)(Java Doc)
|
|
|