public class NumberFormatter extends java.lang.Object implements IFormatter
IFormatter.DefaultFormatter| 限定符和类型 | 字段和说明 |
|---|---|
protected java.text.DecimalFormat |
decimalFormat |
protected char |
decimalSeparator
The default format of Double is Double.toString(); need to localize the
result of Double.toString() to get the final result.
|
protected java.lang.String |
formatPattern
the format pattern
|
protected com.ibm.icu.util.ULocale |
locale
the locale used for formatting
|
protected static java.util.logging.Logger |
logger
logger used to log syntax errors.
|
protected java.text.NumberFormat |
numberFormat
a java.text.NumberFormat format object.
|
protected boolean |
parseBigDecimal
Flag whether to parse numbers and return BigDecimal values.
|
| 构造器和说明 |
|---|
NumberFormatter()
constructor with no argument
|
NumberFormatter(java.util.Locale locale)
已过时。
since 2.1
|
NumberFormatter(java.lang.String format)
constructor with a format string as parameter
|
NumberFormatter(java.lang.String pattern,
java.util.Locale locale)
已过时。
since 2.1
|
NumberFormatter(java.lang.String pattern,
com.ibm.icu.util.ULocale locale)
constructor that takes a format pattern and a locale
|
NumberFormatter(com.ibm.icu.util.ULocale locale) |
| 限定符和类型 | 方法和说明 |
|---|---|
void |
applyPattern(java.lang.String patternStr)
initializes numeric format pattern
|
java.lang.String |
format(java.math.BigDecimal bigDecimal)
formats a BigDecimal value into a string
|
java.lang.String |
format(double num) |
java.lang.String |
format(long num)
formats a long integer
|
java.lang.String |
format(java.lang.Number number) |
java.lang.String |
formatValue(java.lang.Object value)
format the value object into a string.
|
java.lang.String |
getFormatCode() |
java.lang.String |
getPattern()
returns the original format string.
|
boolean |
isParseBigDecimal()
Returns whether decimal numbers are returned as BigDecimal instances.
|
java.lang.Number |
parse(java.lang.String number)
Parses the input string into a formatted date type.
|
void |
setParseBigDecimal(boolean parseBigDecimal)
Sets whether decimal numbers must be returned as BigDecimal instances.
|
protected static java.util.logging.Logger logger
protected java.lang.String formatPattern
protected boolean parseBigDecimal
protected com.ibm.icu.util.ULocale locale
protected java.text.NumberFormat numberFormat
protected java.text.DecimalFormat decimalFormat
protected char decimalSeparator
of java.text.DecimalFormatSymbols#exponentialpublic NumberFormatter()
public NumberFormatter(java.lang.String format)
format - format stringpublic NumberFormatter(com.ibm.icu.util.ULocale locale)
locale - the locale used for numer formatpublic NumberFormatter(java.util.Locale locale)
public NumberFormatter(java.lang.String pattern,
com.ibm.icu.util.ULocale locale)
pattern - numeric format patternlocale - locale used to format the numberpublic NumberFormatter(java.lang.String pattern,
java.util.Locale locale)
public java.lang.String getPattern()
public java.lang.String getFormatCode()
public void applyPattern(java.lang.String patternStr)
patternStr - ths string used for formatting numeric datapublic java.lang.String format(double num)
num - the number to be formattedpublic java.lang.String format(java.math.BigDecimal bigDecimal)
big - decimal valuepublic java.lang.String format(java.lang.Number number)
public java.lang.String format(long num)
num - the number to be formattedpublic boolean isParseBigDecimal()
public void setParseBigDecimal(boolean parseBigDecimal)
parseBigDecimal - the parseBigDecimal to setpublic java.lang.Number parse(java.lang.String number)
throws java.text.ParseException
number - the input string to parsejava.text.ParseException - if the beginning of the specified string cannot be parsed.public java.lang.String formatValue(java.lang.Object value)
IFormatterformatValue 在接口中 IFormatterCopyright © 2008 Actuate Corp. All rights reserved.