Top Description Fields Constructors Methods
org.apache.poi.ss.usermodel

public Class ExcelGeneralNumberFormat

extends Format
Class Inheritance
Imports
java.math.BigDecimal, .MathContext, .RoundingMode, java.text.DecimalFormat, .DecimalFormatSymbols, .FieldPosition, .Format, .ParsePosition, java.util.Locale

A format that formats a double as Excel would, ignoring FieldPosition. All other operations are unsupported.

Field Summary

Modifier and TypeField and Description
private final DecimalFormat
private final DecimalFormatSymbols
private final DecimalFormat
private final DecimalFormat
private static final long
private static final MathContext

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public StringBuffer
format(Object
The object to format
number
,
StringBuffer
where the text is to be appended
toAppendTo
,
FieldPosition
A FieldPosition identifying a field in the formatted text
pos
)

Implements abstract java.text.Format.format.

Formats an object and appends the resulting text to a given string buffer.

public Object
parseObject(String
the String to parse
source
,
ParsePosition
A ParsePosition object with index and error index information as described above.
pos
)

Implements abstract java.text.Format.parseObject.

Parses text from the given string to produce an object.

Inherited from java.text.Format:
cloneformatformatToCharacterIteratorparseObject

Field Detail

decimalFormatback to summary
private final DecimalFormat decimalFormat
decimalSymbolsback to summary
private final DecimalFormatSymbols decimalSymbols
integerFormatback to summary
private final DecimalFormat integerFormat
scientificFormatback to summary
private final DecimalFormat scientificFormat
serialVersionUIDback to summary
private static final long serialVersionUID

Hides java.text.Format.serialVersionUID.

TO_10_SFback to summary
private static final MathContext TO_10_SF

Constructor Detail

ExcelGeneralNumberFormatback to summary
public ExcelGeneralNumberFormat(final Locale locale)

Method Detail

formatback to summary
public StringBuffer format(Object number, StringBuffer toAppendTo, FieldPosition pos)

Implements abstract java.text.Format.format.

Doc from java.text.Format.format.

Formats an object and appends the resulting text to a given string buffer. If the pos argument identifies a field used by the format, then its indices are set to the beginning and end of the first such field encountered.

Parameters
number:Object

The object to format

toAppendTo:StringBuffer

where the text is to be appended

pos:FieldPosition

A FieldPosition identifying a field in the formatted text

Returns:StringBuffer

the string buffer passed in as toAppendTo, with formatted text appended

Annotations
@SuppressWarnings:squid:S2111
parseObjectback to summary
public Object parseObject(String source, ParsePosition pos)

Implements abstract java.text.Format.parseObject.

Doc from java.text.Format.parseObject.

Parses text from the given string to produce an object.

This method attempts to parse text starting at the index given by pos. If parsing succeeds, then the index of pos is updated to the index after the last character used (parsing does not necessarily use all characters up to the end of the string), and the parsed object is returned. The updated pos can be used to indicate the starting point for the next call to this method. If an error occurs, then the index of pos is not changed, the error index of pos is set to the index of the character where the error occurred, and null is returned.

Parameters
source:String

the String to parse

pos:ParsePosition

A ParsePosition object with index and error index information as described above.

Returns:Object

An Object parsed from the string. In case of error, returns null.