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

public Class ExcelStyleDateFormatter

extends SimpleDateFormat
Class Inheritance
Imports
java.math.RoundingMode, java.text.DateFormatSymbols, .DecimalFormat, .DecimalFormatSymbols, .FieldPosition, .SimpleDateFormat, java.util.Date, .Locale, org.apache.poi.util.LocaleUtil

A wrapper around a SimpleDateFormat instance, which handles a few Excel-style extensions that are not supported by SimpleDateFormat. Currently, the extensions are around the handling of elapsed time, eg rendering 1 day 2 hours as 26 hours.

Field Summary

Modifier and TypeField and Description
private double
private static final DecimalFormat
private static final DecimalFormat
private static final DecimalFormat
private static final DecimalFormat
public static final char
public static final char
public static final char
public static final char
public static final char
public static final char
public static final char
public static final char
public static final char
public static final char

Constructor Summary

AccessConstructor and Description
public
public
public

Method Summary

Modifier and TypeMethod and Description
public boolean
equals(Object
object to be compared for equality
o
)

Overrides java.text.SimpleDateFormat.equals.

Compares the specified object with this SimpleDateFormat for equality.

public StringBuffer
format(Date
the date-time value to be formatted into a date-time string.
date
,
StringBuffer
where the new date-time text is to be appended.
paramStringBuffer
,
FieldPosition
keeps track on the position of the field within the returned string. For example, given a date-time text "1996.07.10 AD at 15:08:56 PDT", if the given fieldPosition is DateFormat#YEAR_FIELD, the begin index and end index of fieldPosition will be set to 0 and 4, respectively. Notice that if the same date-time field appears more than once in a pattern, the fieldPosition will be set for the first occurrence of that date-time field. For instance, formatting a Date to the date-time string "1 PM PDT (Pacific Daylight Time)" using the pattern "h a z (zzzz)" and the alignment field DateFormat#TIMEZONE_FIELD, the begin index and end index of fieldPosition will be set to 5 and 8, respectively, for the first occurrence of the timezone pattern character 'z'.
paramFieldPosition
)

Overrides java.text.SimpleDateFormat.format.

Formats the given Date into a date/time string and appends the result to the given StringBuffer.

public int
hashCode()

Overrides java.text.SimpleDateFormat.hashCode.

Returns the hash code value for this SimpleDateFormat.

private static String
processFormatPattern(String f)

Takes a format String, and replaces Excel specific bits with our detection sequences

public void
setDateToBeFormatted(double date)

Used to let us know what the date being formatted is, in Excel terms, which we may wish to use when handling elapsed times.

Inherited from java.text.SimpleDateFormat:
applyLocalizedPatternapplyPatterncloneformatToCharacterIteratorget2DigitYearStartgetDateFormatSymbolsparseset2DigitYearStartsetDateFormatSymbolstoLocalizedPatterntoPatterntoString

Field Detail

dateToBeFormattedback to summary
private double dateToBeFormatted
format1digitback to summary
private static final DecimalFormat format1digit
format2digitsback to summary
private static final DecimalFormat format2digits
format3digitback to summary
private static final DecimalFormat format3digit
format4digitsback to summary
private static final DecimalFormat format4digits
H_BRACKET_SYMBOLback to summary
public static final char H_BRACKET_SYMBOL
HH_BRACKET_SYMBOLback to summary
public static final char HH_BRACKET_SYMBOL
L_BRACKET_SYMBOLback to summary
public static final char L_BRACKET_SYMBOL
LL_BRACKET_SYMBOLback to summary
public static final char LL_BRACKET_SYMBOL
M_BRACKET_SYMBOLback to summary
public static final char M_BRACKET_SYMBOL
MM_BRACKET_SYMBOLback to summary
public static final char MM_BRACKET_SYMBOL
MMMMM_START_SYMBOLback to summary
public static final char MMMMM_START_SYMBOL
MMMMM_TRUNCATE_SYMBOLback to summary
public static final char MMMMM_TRUNCATE_SYMBOL
S_BRACKET_SYMBOLback to summary
public static final char S_BRACKET_SYMBOL
SS_BRACKET_SYMBOLback to summary
public static final char SS_BRACKET_SYMBOL

Constructor Detail

ExcelStyleDateFormatterback to summary
public ExcelStyleDateFormatter(String pattern)
ExcelStyleDateFormatterback to summary
public ExcelStyleDateFormatter(String pattern, DateFormatSymbols formatSymbols)
ExcelStyleDateFormatterback to summary
public ExcelStyleDateFormatter(String pattern, Locale locale)

Method Detail

equalsback to summary
public boolean equals(Object o)

Overrides java.text.SimpleDateFormat.equals.

Doc from java.text.SimpleDateFormat.equals.

Compares the specified object with this SimpleDateFormat for equality. Returns true if the object is also a SimpleDateFormat and the two formats would format any value the same.

Parameters
o:Object

object to be compared for equality

Returns:boolean

true if the specified object is equal to this SimpleDateFormat

Annotations
@Override
formatback to summary
public StringBuffer format(Date date, StringBuffer paramStringBuffer, FieldPosition paramFieldPosition)

Overrides java.text.SimpleDateFormat.format.

Doc from java.text.SimpleDateFormat.format.

Formats the given Date into a date/time string and appends the result to the given StringBuffer.

Parameters
date:Date

the date-time value to be formatted into a date-time string.

paramStringBuffer:StringBuffer

where the new date-time text is to be appended.

paramFieldPosition:FieldPosition

keeps track on the position of the field within the returned string. For example, given a date-time text "1996.07.10 AD at 15:08:56 PDT", if the given fieldPosition is DateFormat#YEAR_FIELD, the begin index and end index of fieldPosition will be set to 0 and 4, respectively. Notice that if the same date-time field appears more than once in a pattern, the fieldPosition will be set for the first occurrence of that date-time field. For instance, formatting a Date to the date-time string "1 PM PDT (Pacific Daylight Time)" using the pattern "h a z (zzzz)" and the alignment field DateFormat#TIMEZONE_FIELD, the begin index and end index of fieldPosition will be set to 5 and 8, respectively, for the first occurrence of the timezone pattern character 'z'.

Returns:StringBuffer

the formatted date-time string.

Annotations
@Override
hashCodeback to summary
public int hashCode()

Overrides java.text.SimpleDateFormat.hashCode.

Doc from java.text.SimpleDateFormat.hashCode.

Returns the hash code value for this SimpleDateFormat.

Returns:int

the hash code value for this SimpleDateFormat

Annotations
@Override
processFormatPatternback to summary
private static String processFormatPattern(String f)

Takes a format String, and replaces Excel specific bits with our detection sequences

setDateToBeFormattedback to summary
public void setDateToBeFormatted(double date)

Used to let us know what the date being formatted is, in Excel terms, which we may wish to use when handling elapsed times.