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 |
|---|---|
default String |
format(T formattable)
Synonym for
print(T). |
AttributeQuery |
getAttributes()
Determines all global format attributes if available.
|
T |
parse(CharSequence text)
Interpretes given text as chronological entity.
|
T |
parse(CharSequence text,
RawValues rawValues)
Interpretes given text as chronological entity and updates given raw values.
|
String |
print(T formattable)
Prints given chronological entity as formatted text.
|
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.
|
default String format(T formattable)
Synonym for print(T).
This method adapts the standard naming style of most Java formatters while Time4J prefers the name "print".
formattable - object to be formattedIllegalArgumentException - if given object is not formattableString print(T formattable)
Prints given chronological entity as formatted text.
formattable - object to be formattedIllegalArgumentException - if given object is not formattableT parse(CharSequence text) throws ParseException
Interpretes given text as chronological entity.
text - text to be parsedIndexOutOfBoundsException - if the text is emptyParseException - if the text is not parseableT parse(CharSequence text, RawValues rawValues) throws ParseException
Interpretes given text as chronological entity and updates given raw values.
text - text to be parsedrawValues - holder for raw values (always as new instance)IndexOutOfBoundsException - if the start position is at end of text or even behindParseException - if parsing does not workTemporalFormatter<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 idIllegalArgumentException - if timezone data cannot be loadedAttributes.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–2021. All rights reserved.