T - generic type of applicable chronological typespublic interface TemporalFormatter<T>
Generic facade for any temporal/chronological format object which can print temporal objects to text or parse texts to temporal objects.
| Modifier and Type | Method and Description |
|---|---|
String |
format(T formattable)
Prints given chronological entity as formatted text.
|
void |
formatToBuffer(T formattable,
Appendable buffer)
Prints given chronological entity as formatted text and writes it to given buffer.
|
AttributeQuery |
getAttributes()
Determines all global format attributes if available.
|
T |
parse(CharSequence text)
Interpretes given text as chronological entity starting
at the begin of text.
|
T |
parse(CharSequence text,
ParsePosition position)
Interpretes given text as chronological entity starting
at the specified position.
|
T |
parse(CharSequence text,
ParsePosition position,
RawValues rawValues)
Interpretes given text as chronological entity starting
at the specified position.
|
TemporalFormatter<T> |
with(Leniency leniency)
Sets the leniency mode.
|
TemporalFormatter<T> |
with(Locale locale)
Creates a copy of this formatter with given locale.
|
TemporalFormatter<T> |
withTimezone(String tzid)
Equivalent to
withTimezone(Timezone.of(tzid).getID()). |
TemporalFormatter<T> |
withTimezone(TZID tzid)
Creates a copy of this formatter with given timezone id which
shall be used in formatting or parsing.
|
String format(T formattable)
Prints given chronological entity as formatted text.
formattable - object to be formattedIllegalArgumentException - if given object is not formattablevoid formatToBuffer(T formattable, Appendable buffer) throws IOException
Prints given chronological entity as formatted text and writes it to given buffer.
formattable - object to be formattedbuffer - format bufferIllegalArgumentException - if given object is not formattableIOException - if writing to the buffer failsT parse(CharSequence text) throws ParseException
Interpretes given text as chronological entity starting at the begin of text.
text - text to be parsedIndexOutOfBoundsException - if the text is emptyParseException - if the text is not parseableT parse(CharSequence text, ParsePosition position)
Interpretes given text as chronological entity starting at the specified position.
text - text to be parsedposition - parse position (always as new instance)null if parsing does not workIndexOutOfBoundsException - if the start position is at end of text or even behindT parse(CharSequence text, ParsePosition position, RawValues rawValues)
Interpretes given text as chronological entity starting at the specified position.
text - text to be parsedposition - parse position (always as new instance)rawValues - holder for raw values (always as new instance)null if parsing does not workIndexOutOfBoundsException - if the start position is at end of text or even behindTemporalFormatter<T> withTimezone(TZID tzid)
Creates a copy of this formatter with given timezone id which shall be used in formatting or parsing.
The timezone is in most cases only relevant for the type
Moment. When formatting the timezone helps
to convert the UTC value into a zonal representation. When
parsing the timezone serves as replacement value if the formatted
text does not contain any timezone.
tzid - timezone idAttributes.TIMEZONE_IDTemporalFormatter<T> withTimezone(String tzid)
Equivalent to withTimezone(Timezone.of(tzid).getID()).
tzid - timezone idIllegalArgumentException - if given timezone cannot be loadedwithTimezone(TZID),
Attributes.TIMEZONE_IDTemporalFormatter<T> with(Locale locale)
Creates a copy of this formatter with given locale.
Note that changing the locale cannot change the inner structure of this formatter even if the structure is no longer appropriate for given locale. An example is the English AM/PM-pattern which will be preserved even if the language changes from English to German.
locale - new language and country configurationTemporalFormatter<T> with(Leniency leniency)
Sets the leniency mode.
By default any temporal formatter is smart.
leniency - determines how strict the parser should beAttributes.LENIENCYAttributeQuery getAttributes()
Determines all global format attributes if available.
Global attributes are valid for the whole formatter. Sectional attributes which might exist and control the behaviour of only a part of the formatter cannot be overridden.
Copyright © 2014–2017. All rights reserved.