Package org.apache.commons.lang3.time
Class FastDatePrinter.EraField
java.lang.Object
org.apache.commons.lang3.time.FastDatePrinter.EraField
- All Implemented Interfaces:
FastDatePrinter.Rule
- Enclosing class:
- FastDatePrinter
Inner class to output the era name of the calendar being formatted.
DateFormatSymbols.getEras() only knows the two Gregorian eras. A locale whose default calendar is not Gregorian, like the Thai Buddhist or
Japanese Imperial calendar, prints that calendar's year, so the era names have to come from that calendar as well, as SimpleDateFormat and
FastDateParser do. The Japanese Imperial calendar also has more than two eras, so indexing the Gregorian names by its era value would throw an
ArrayIndexOutOfBoundsException.
FastDatePrinter.format(Calendar) applies the rules to the caller's calendar, which need not be of the type the locale defaults to. An era value
only has a meaning in the calendar it comes from, so the names are picked by the type of the calendar being formatted.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidappendTo(Appendable buffer, Calendar calendar) Appends the value of the specified calendar to the output buffer based on the rule implementation.intReturns the estimated length of the result.
-
Field Details
-
GREGORY
The calendar type of a Gregorian calendar.- See Also:
-
calendarType
-
values
-
gregorianValues
-
style
private final int style -
locale
-
-
Constructor Details
-
EraField
Constructs an instance ofFastDatePrinter.EraField.- Parameters:
calendar- A calendar of the type the printer's locale defaults to.gregorianValues- The Gregorian era names.style-Calendar.SHORTorCalendar.LONG.locale- The locale.
-
-
Method Details
-
appendTo
Appends the value of the specified calendar to the output buffer based on the rule implementation.- Specified by:
appendToin interfaceFastDatePrinter.Rule- Parameters:
buffer- The output buffer.calendar- calendar to be appended.- Throws:
IOException- Thrown if an I/O error occurs.
-
estimateLength
public int estimateLength()Returns the estimated length of the result.- Specified by:
estimateLengthin interfaceFastDatePrinter.Rule- Returns:
- The estimated length of the result.
-