public class NumberFormatter extends java.lang.Object implements IFormatter
IFormatter.DefaultFormatter
Modifier and Type | Field and Description |
---|---|
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 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.
|
Constructor and Description |
---|
NumberFormatter()
constructor with no argument
|
NumberFormatter(java.lang.String format)
constructor with a format string as parameter
|
NumberFormatter(java.lang.String pattern,
ULocale locale)
constructor that takes a format pattern and a locale
|
NumberFormatter(ULocale locale) |
Modifier and Type | Method and Description |
---|---|
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 ULocale locale
protected java.text.NumberFormat numberFormat
protected java.text.DecimalFormat decimalFormat
protected char decimalSeparator
of java.text.DecimalFormatSymbols#exponential
public NumberFormatter()
public NumberFormatter(java.lang.String format)
format
- format stringpublic NumberFormatter(ULocale locale)
locale
- the locale used for numer formatpublic NumberFormatter(java.lang.String pattern, ULocale locale)
pattern
- numeric format patternlocale
- locale used to format the numberpublic 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)
IFormatter
formatValue
in interface IFormatter
Copyright © 2014 OpenText Corp. All rights reserved.