public class DataFormatter extends Object
DataFormatter
.Made some optimizations for date
conversion.
This is a non-thread-safe class.
构造器和说明 |
---|
DataFormatter(GlobalConfiguration globalConfiguration)
Creates a formatter using the given locale.
|
限定符和类型 | 方法和说明 |
---|---|
void |
addFormat(String excelFormatStr,
Format format)
Adds a new format to the available formats.
|
String |
format(BigDecimal data,
Integer dataFormat,
String dataFormatString)
Format data.
|
void |
setDefaultNumberFormat(Format format)
Sets a default number format to be used when the Excel format cannot be parsed successfully.
|
static void |
setExcelStyleRoundingMode(DecimalFormat format)
Enables excel style rounding mode (round half up) on the Decimal Format given.
|
static void |
setExcelStyleRoundingMode(DecimalFormat format,
RoundingMode roundingMode)
Enables custom rounding mode on the given Decimal Format.
|
public DataFormatter(GlobalConfiguration globalConfiguration)
public String format(BigDecimal data, Integer dataFormat, String dataFormatString)
data
- dataFormat
- dataFormatString
- public void setDefaultNumberFormat(Format format)
Sets a default number format to be used when the Excel format cannot be parsed successfully. Note: This is a fall back for when an error occurs while parsing an Excel number format pattern. This will not affect cells with the General format.
The value that will be passed to the Format's format method (specified by java.text.Format#format
)
will be a double value from a numeric cell. Therefore the code in the format method should expect a
Number
value.
format
- A Format instance to be used as a defaultFormat.format(java.lang.Object)
public void addFormat(String excelFormatStr, Format format)
The value that will be passed to the Format's format method (specified by java.text.Format#format
)
will be a double value from a numeric cell. Therefore the code in the format method should expect a
Number
value.
excelFormatStr
- The data format stringformat
- A Format instancepublic static void setExcelStyleRoundingMode(DecimalFormat format)
public static void setExcelStyleRoundingMode(DecimalFormat format, RoundingMode roundingMode)
format
- DecimalFormatroundingMode
- RoundingModeCopyright © 2018–2021 Alibaba Group. All rights reserved.