T - generic type of chronological entitypublic final class ChronoFormatter<T> extends Object implements ChronoPrinter<T>, ChronoParser<T>, TemporalFormatter<T>
Represents a chronological format for the conversion between a chronological text and the chronological value of type T.
An instance can either be created via a Builder obtainable
by setUp(Class, Locale) or by some static factory methods.
The class Iso8601Format provides additional formatters
adapted for the ISO-8601-standard.
Interoperability note:
The static methods setUp(Chronology, Locale) and
ofPattern(String, PatternType, Locale, Chronology) also
allow the usage of foreign types by specifying a suitable bridge
chronology. Even the old type java.util.Date can be
used in conjunction with this formatter. Example:
ChronoFormatter<java.util.Date> f =
ChronoFormatter.ofPattern(
"MM/dd/yyyy",
PatternType.CLDR,
Locale.US,
Moment.axis(TemporalType.JAVA_UTIL_DATE))
.withDefault(PlainTime.COMPONENT, PlainTime.midnightAtStartOfDay())
.withStdTimezone();
System.out.println(f.format(new java.util.Date()));
java.util.Date d = f.parse("10/26/2016");
| Modifier and Type | Class and Description |
|---|---|
static class |
ChronoFormatter.Builder<T>
Builder for creating a new
ChronoFormatter. |
| Modifier and Type | Field and Description |
|---|---|
static ChronoFormatter<Moment> |
RFC_1123
Special formatter for printing or parsing moments according
to the RFC-1123-specification.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
equals(Object obj)
Compares the chronologies, default attributes, default values and
the internal format structures.
|
String |
format(GeneralTimestamp<?> tsp)
Prints given general timestamp.
|
String |
format(T formattable)
Prints given chronological entity as formatted text.
|
String |
formatThreeten(TemporalAccessor formattable)
Deprecated.
Use alternative approach based on static factory methods and bridge chronology
|
void |
formatToBuffer(T formattable,
Appendable buffer) |
AttributeQuery |
getAttributes()
Returns the global format attributes which are active if they are not
overridden by sectional attributes.
|
Chronology<T> |
getChronology()
Returns the associated chronology.
|
Locale |
getLocale()
Returns the locale setting.
|
int |
hashCode() |
static ChronoFormatter<PlainDate> |
ofDatePattern(String pattern,
PatternType type,
Locale locale)
Constructs a pattern-based formatter for plain date objects.
|
static ChronoFormatter<PlainDate> |
ofDateStyle(DisplayMode style,
Locale locale)
Constructs a style-based formatter for plain date objects.
|
static ChronoFormatter<Moment> |
ofMomentPattern(String pattern,
PatternType type,
Locale locale,
TZID tzid)
Constructs a pattern-based formatter for global timestamp objects.
|
static ChronoFormatter<Moment> |
ofMomentStyle(DisplayMode dateStyle,
DisplayMode timeStyle,
Locale locale,
TZID tzid)
Constructs a style-based formatter for moments.
|
static <T> ChronoFormatter<T> |
ofPattern(String pattern,
PatternType type,
Locale locale,
Chronology<T> chronology)
Constructs a pattern-based formatter for general chronologies.
|
static <T extends LocalizedPatternSupport> |
ofStyle(DisplayStyle style,
Locale locale,
Chronology<T> chronology)
Constructs a style-based formatter for general chronologies.
|
static ChronoFormatter<PlainTime> |
ofTimePattern(String pattern,
PatternType type,
Locale locale)
Constructs a pattern-based formatter for clock time objects.
|
static ChronoFormatter<PlainTimestamp> |
ofTimestampPattern(String pattern,
PatternType type,
Locale locale)
Constructs a pattern-based formatter for plain timestamps.
|
static ChronoFormatter<PlainTimestamp> |
ofTimestampStyle(DisplayMode dateStyle,
DisplayMode timeStyle,
Locale locale)
Constructs a style-based formatter for plain timestamps.
|
static ChronoFormatter<PlainTime> |
ofTimeStyle(DisplayMode style,
Locale locale)
Constructs a style-based formatter for plain date objects.
|
T |
parse(CharSequence text)
Interpretes given text as chronological entity starting
at the begin of text.
|
T |
parse(CharSequence text,
ParseLog status)
Interpretes given text as chronological entity starting
at the specified position in parse log.
|
T |
parse(CharSequence text,
ParseLog status,
AttributeQuery attributes)
Interpretes given text as chronological entity starting
at the specified position in parse log.
|
T |
parse(CharSequence text,
ParsePosition position)
For maximum information use
parse(CharSequence, ParseLog) instead. |
T |
parse(CharSequence text,
ParsePosition position,
RawValues rawValues) |
ChronoEntity<?> |
parseRaw(CharSequence text,
int offset)
Translates given text as raw chronological entity without
converting to the target type of the underlying chronology.
|
ChronoEntity<?> |
parseRaw(String text)
Translates given text as raw chronological entity without
converting to the target type of the underlying chronology.
|
Set<ElementPosition> |
print(T formattable,
Appendable buffer,
AttributeQuery attributes)
Prints given chronological entity as formatted text and writes
the text into given buffer.
|
<R> R |
print(T formattable,
Appendable buffer,
AttributeQuery attributes,
ChronoFunction<ChronoDisplay,R> query)
Deprecated.
|
Set<ElementPosition> |
print(T formattable,
StringBuilder buffer,
AttributeQuery attributes)
Prints given chronological entity as formatted text and writes
the text into given buffer.
|
Set<ElementPosition> |
printThreeten(TemporalAccessor formattable,
Appendable buffer)
Deprecated.
Use alternative approach based on static factory methods and bridge chronology
|
static <T> ChronoFormatter.Builder<T> |
setUp(Chronology<T> chronology,
Locale locale)
Constructs a builder for creating formatters.
|
static <T extends ChronoEntity<T>> |
setUp(Class<T> type,
Locale locale)
Constructs a builder for creating formatters.
|
static <C extends CalendarVariant<C>> |
setUpWithOverride(Locale locale,
CalendarFamily<C> overrideCalendar)
Constructs a builder for creating global formatters with usage of given calendar type.
|
static <C extends Calendrical<?,C>> |
setUpWithOverride(Locale locale,
Chronology<C> overrideCalendar)
Constructs a builder for creating global formatters with usage of given calendar type.
|
Format |
toFormat()
Converts this formatter into a traditional
java.text.Format-object. |
String |
toString()
For debugging purposes.
|
<A extends Enum<A>> |
with(AttributeKey<A> key,
A value)
Creates a copy of this formatter with given enum-attribute.
|
ChronoFormatter<T> |
with(AttributeKey<Boolean> key,
boolean value)
Creates a copy of this formatter with given boolean-attribute.
|
ChronoFormatter<T> |
with(AttributeKey<Character> key,
char value)
Creates a copy of this formatter with given char-attribute.
|
ChronoFormatter<T> |
with(AttributeKey<Integer> key,
int value)
Creates a copy of this formatter with given int-attribute.
|
ChronoFormatter<T> |
with(Attributes attributes)
Creates a copy of this formatter with given standard attributes.
|
ChronoFormatter<T> |
with(ChronoHistory history)
Creates a copy of this formatter with the given chronological history of gregorian calendar reforms.
|
ChronoFormatter<T> |
with(Leniency leniency) |
ChronoFormatter<T> |
with(Locale locale)
Creates a copy of this formatter with given locale.
|
ChronoFormatter<T> |
with(StartOfDay startOfDay)
Sets the start of calendar day.
|
ChronoFormatter<T> |
with(Timezone tz)
Creates a copy of this formatter with given timezone which
shall be used in formatting or parsing.
|
ChronoFormatter<T> |
withAlternativeEraNames()
Creates a copy of this formatter with alternative era names.
|
ChronoFormatter<T> |
withCalendarVariant(String variant)
Sets the calendar variant.
|
ChronoFormatter<T> |
withCalendarVariant(VariantSource variantSource)
Sets the calendar variant.
|
<V> ChronoFormatter<T> |
withDefault(ChronoElement<V> element,
V value)
Determines a default replacement value for given element.
|
<V> ChronoFormatter<T> |
withDefaultSource(ChronoElement<V> element,
ChronoElement<V> source)
Determines a source reference in parsed data for a default replacement value of given element.
|
<V> ChronoFormatter<T> |
withDefaultSupplier(ChronoElement<V> element,
Supplier<V> supplier)
Determines a supplier for a default replacement value of given element.
|
ChronoFormatter<T> |
withGregorianCutOver(PlainDate date)
Short-cut for
with(ChronoHistory.ofGregorianReform(date)). |
ChronoFormatter<T> |
withLatinEraNames()
Creates a copy of this formatter with latin era names.
|
ChronoFormatter<T> |
withStdTimezone()
Equivalent to
with(Timezone.ofSystem()). |
ChronoFormatter<T> |
withTimezone(String tzid)
Equivalent to
with(Timezone.of(tzid)). |
ChronoFormatter<T> |
withTimezone(TZID tzid)
Equivalent to
with(Timezone.of(tzid)). |
printpublic static final ChronoFormatter<Moment> RFC_1123
Special formatter for printing or parsing moments according to the RFC-1123-specification.
Note: Military timezones with the exception of Z (=UTC) are NOT supported because the specification had originally given the offset signs in reverse way from UTC (an error in RFC-822). However, north american timezone names are supported (EST/EDT/CST/CDT/MST/MDT/PST/PDT).
public Chronology<T> getChronology()
Returns the associated chronology.
public Locale getLocale()
Returns the locale setting.
If there is just a reference to ISO-8601 without any concrete
language then this method will yield Locale.ROOT.
null)public AttributeQuery getAttributes()
Returns the global format attributes which are active if they are not overridden by sectional attributes.
The global attributes can be adjusted by a suitable
with()-method. Following attributes are predefined:
Attributes.CALENDAR_TYPE |
read-only, dependent on associated chronology |
Attributes.LANGUAGE |
dependent on associated locale |
Attributes.DECIMAL_SEPARATOR |
dependent on associated locale |
Attributes.ZERO_DIGIT |
dependent on associated locale |
Attributes.LENIENCY |
Leniency.SMART |
Attributes.PARSE_CASE_INSENSITIVE |
true |
Attributes.PARSE_PARTIAL_COMPARE |
false |
Attributes.TEXT_WIDTH |
TextWidth.WIDE |
Attributes.OUTPUT_CONTEXT |
OutputContext.FORMAT |
Attributes.PAD_CHAR |
(SPACE) |
getAttributes in interface ChronoParser<T>getAttributes in interface ChronoPrinter<T>getAttributes in interface TemporalFormatter<T>getChronology(),
getLocale()public String format(T formattable)
ChronoPrinterPrints given chronological entity as formatted text.
format in interface ChronoPrinter<T>format in interface TemporalFormatter<T>formattable - object to be formattedpublic String format(GeneralTimestamp<?> tsp)
Prints given general timestamp.
tsp - general timestamp as combination of a date and a timeIllegalArgumentException - if the timestamp is not formattable with this formatter@Deprecated public String formatThreeten(TemporalAccessor formattable)
Prints the given Threeten-object.
formattable - temporal accessorIllegalArgumentException - if given argument cannot be formattedpublic void formatToBuffer(T formattable, Appendable buffer) throws IOException
formatToBuffer in interface TemporalFormatter<T>IOExceptionpublic Set<ElementPosition> print(T formattable, StringBuilder buffer, AttributeQuery attributes)
ChronoPrinterPrints given chronological entity as formatted text and writes the text into given buffer.
Starting with v5.0, this method will become the SAM-method of this interface and has to be implemented in any suitable way.
print in interface ChronoPrinter<T>formattable - object to be formattedbuffer - text output bufferattributes - format attributes which can control formatting@Deprecated public Set<ElementPosition> printThreeten(TemporalAccessor formattable, Appendable buffer) throws IOException
Prints given Threeten-object as formatted text and writes the text into given buffer.
Similar to print(formattable, buffer, getAttributes()).
formattable - object to be formattedbuffer - text output bufferIllegalArgumentException - if given object is not formattableIOException - if writing to buffer failspublic Set<ElementPosition> print(T formattable, Appendable buffer, AttributeQuery attributes) throws IOException
Prints given chronological entity as formatted text and writes the text into given buffer.
The given attributes cannot change the inner format structure (for example not change a localized weekmodel), but can override some format properties like language or certain text attributes for this run only.
formattable - object to be formattedbuffer - text output bufferattributes - attributes for limited formatting controlIllegalArgumentException - if given object is not formattableIOException - if writing to buffer fails@Deprecated public <R> R print(T formattable, Appendable buffer, AttributeQuery attributes, ChronoFunction<ChronoDisplay,R> query) throws IOException
ChronoPrinterCreates a text output and writes it into given buffer.
Note: Implementations have to call query.apply(...)
at the end to return a possibly meaningful result. An example
would be a query which produces just the identical input so
the result of printing a Moment will be the formatted
form of the original Moment.
print in interface ChronoPrinter<T>R - generic result typeformattable - chronological entity to be formattedbuffer - format buffer any text output will be sent toattributes - control attributesquery - custom query returning any kind of resultIOException - if writing into buffer failspublic T parse(CharSequence text) throws ParseException
ChronoParserInterpretes given text as chronological entity starting at the begin of text.
parse in interface ChronoParser<T>parse in interface TemporalFormatter<T>text - text to be parsedParseException - if the text is not parseablepublic T parse(CharSequence text, ParseLog status)
ChronoParserInterpretes given text as chronological entity starting at the specified position in parse log.
Equivalent to parse(text, status, getAttributes()).
parse in interface ChronoParser<T>text - text to be parsedstatus - parser information (always as new instance)null if parsing does not workpublic T parse(CharSequence text, ParsePosition position)
For maximum information use parse(CharSequence, ParseLog) instead.
parse in interface TemporalFormatter<T>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 behindpublic T parse(CharSequence text, ParsePosition position, RawValues rawValues)
parse in interface TemporalFormatter<T>public T parse(CharSequence text, ParseLog status, AttributeQuery attributes)
Interpretes given text as chronological entity starting at the specified position in parse log.
The given attributes cannot change the inner format structure (for example not change a localized weekmodel), but can override some format properties like expected language or certain text attributes for this run only.
parse in interface ChronoParser<T>text - text to be parsedstatus - parser information (always as new instance)attributes - attributes for limited parsing controlnull if parsing does not workIndexOutOfBoundsException - if the start position is at end of text or even behindpublic ChronoEntity<?> parseRaw(String text)
Translates given text as raw chronological entity without converting to the target type of the underlying chronology.
text - text to be parsedpublic ChronoEntity<?> parseRaw(CharSequence text, int offset)
Translates given text as raw chronological entity without converting to the target type of the underlying chronology.
text - text to be parsedoffset - start positionpublic ChronoFormatter<T> with(Locale locale)
Creates a copy of this formatter with given locale.
Note: Sectional attributes will never be overridden. Is the locale not changed then the method will simply return this instance. Otherwise the copy will contain given locale and also adjusts the associated numerical symbols:
If necessary all inner format elements which are locale-dependent
will also be adjusted. Some country-specific extensions like
Weekmodel.weekOfYear() or ChronoHistory.era()
will only be adjusted if the country-part of given locale is not empty.
However, fixed literals will remain unchanged hence this method might
not be suitable for all languages. Example:
new Locale("sv") will only change the language to swedish
with no side effects, but new Locale("sv", "SE") will also
set the week model and the historical swedish calendar which can be
relevant for the years 1700-1712.
Important: This method cannot adjust localized format
patterns which were maybe generated by applying a format style like
DisplayMode.FULL. Users have to call the style factory
method again with different locale parameter in this case.
with in interface TemporalFormatter<T>locale - new language and country configurationpublic ChronoFormatter<T> with(Leniency leniency)
with in interface TemporalFormatter<T>public ChronoFormatter<T> withAlternativeEraNames()
Creates a copy of this formatter with alternative era names.
Note: Sectional attributes cannot be overridden.
HistoricEra.getAlternativeName(Locale, TextWidth)public ChronoFormatter<T> withLatinEraNames()
Creates a copy of this formatter with latin era names.
Note: Sectional attributes cannot be overridden.
public ChronoFormatter<T> withGregorianCutOver(PlainDate date)
Short-cut for with(ChronoHistory.ofGregorianReform(date)).
date - first gregorian date after gregorian calendar reform takes effectIllegalArgumentException - if given date is before first introduction of gregorian calendar
on 1582-10-15 and not the minimum on the date axisChronoHistory.ofGregorianReform(PlainDate),
with(ChronoHistory)public ChronoFormatter<T> with(ChronoHistory history)
Creates a copy of this formatter with the given chronological history of gregorian calendar reforms.
Note that this configuration will override any gregorian cutover date which might be inferred from current locale.
history - chronological history describing historical calendar reformspublic ChronoFormatter<T> with(Timezone tz)
Creates a copy of this formatter with given timezone 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.
tz - timezoneAttributes.TIMEZONE_ID,
Attributes.TRANSITION_STRATEGYpublic ChronoFormatter<T> withTimezone(TZID tzid)
Equivalent to with(Timezone.of(tzid)).
withTimezone in interface TemporalFormatter<T>tzid - timezone idpublic ChronoFormatter<T> withTimezone(String tzid)
Equivalent to with(Timezone.of(tzid)).
withTimezone in interface TemporalFormatter<T>tzid - timezone idIllegalArgumentException - if given timezone cannot be loadedpublic ChronoFormatter<T> withStdTimezone()
Equivalent to with(Timezone.ofSystem()).
public ChronoFormatter<T> withCalendarVariant(String variant)
Sets the calendar variant.
Some calendars like HijriCalendar require the variant otherwise they cannot be
successfully parsed.
variant - name of new calendar variantAttributes.CALENDAR_VARIANTpublic ChronoFormatter<T> withCalendarVariant(VariantSource variantSource)
Sets the calendar variant.
Some calendars like HijriCalendar require the variant otherwise they cannot be
successfully parsed.
variantSource - source of new calendar variantAttributes.CALENDAR_VARIANTpublic ChronoFormatter<T> with(StartOfDay startOfDay)
Sets the start of calendar day.
startOfDay - new start of dayAttributes.START_OF_DAYpublic <V> ChronoFormatter<T> withDefault(ChronoElement<V> element, V value)
Determines a default replacement value for given element.
Example:
ChronoFormatter<PlainDate> fmt =
PlainDate.localFormatter("MM-dd", PatternType.CLDR)
.withDefault(PlainDate.YEAR, 2012);
PlainDate date = fmt.parse("05-21");
System.out.println(date); // 2012-05-21
Default replacement values will be considered by Time4J if either
the formatter does not contain the element in question at all or if
there are no consumable characters for given element. Latter
situation might sometimes require the use of sectional attribute
PROTECTED_CHARACTERS in order to simulate an end-of-text
situation.
V - generic element value typeelement - chronological element to be updatedvalue - replacement value or null
if the default value shall be deregisteredIllegalArgumentException - if given element is not supported
by the underlying chronologyAttributes.PROTECTED_CHARACTERSpublic <V> ChronoFormatter<T> withDefaultSupplier(ChronoElement<V> element, Supplier<V> supplier)
Determines a supplier for a default replacement value of given element.
Example:
ChronoFormatter<PlainTimestamp> fmt =
ChronoFormatter.ofTimestampPattern("HH:mm", PatternType.CLDR, Locale.ROOT)
.withDefaultSupplier(PlainDate.COMPONENT, () -> SystemClock.inLocalView().today());
PlainTimestamp tsp = fmt.parse("14:45");
System.out.println(tsp); // 2012-05-21T14:45 (example for parsed time on today)
Default replacement values will be considered by Time4J if either
the formatter does not contain the element in question at all or if
there are no consumable characters for given element. Latter
situation might sometimes require the use of sectional attribute
PROTECTED_CHARACTERS in order to simulate an end-of-text
situation.
V - generic element value typeelement - chronological element to be updatedsupplier - supplier for replacement value or null
if the default value shall be deregisteredIllegalArgumentException - if given element is not supported
by the underlying chronologyAttributes.PROTECTED_CHARACTERSpublic <V> ChronoFormatter<T> withDefaultSource(ChronoElement<V> element, ChronoElement<V> source)
Determines a source reference in parsed data for a default replacement value of given element.
Default replacement values will be considered by Time4J if either
the formatter does not contain the element in question at all or if
there are no consumable characters for given element. Latter
situation might sometimes require the use of sectional attribute
PROTECTED_CHARACTERS in order to simulate an end-of-text
situation.
V - generic element value typeelement - chronological element to be updatedsource - element reference in parsed data whose value serves as replacement value
or null if the default value shall be deregisteredIllegalArgumentException - if the first argument is not supported by the underlying chronology
or if both arguments are equalAttributes.PROTECTED_CHARACTERSpublic ChronoFormatter<T> with(AttributeKey<Boolean> key, boolean value)
Creates a copy of this formatter with given boolean-attribute.
Note: Sectional attributes cannot be overridden.
key - attribute keyvalue - attribute valuepublic ChronoFormatter<T> with(AttributeKey<Integer> key, int value)
Creates a copy of this formatter with given int-attribute.
Note: Sectional attributes cannot be overridden.
key - attribute keyvalue - attribute valuepublic ChronoFormatter<T> with(AttributeKey<Character> key, char value)
Creates a copy of this formatter with given char-attribute.
Note: Sectional attributes cannot be overridden.
key - attribute keyvalue - attribute valuepublic <A extends Enum<A>> ChronoFormatter<T> with(AttributeKey<A> key, A value)
Creates a copy of this formatter with given enum-attribute.
Note: Sectional attributes cannot be overridden.
A - generic attribute value typekey - attribute keyvalue - attribute valuepublic ChronoFormatter<T> with(Attributes attributes)
Creates a copy of this formatter with given standard attributes.
Note: Sectional attributes cannot be overridden.
attributes - new default attributespublic Format toFormat()
Converts this formatter into a traditional
java.text.Format-object.
The returned format object also supports attributed strings such
that all ChronoElement-structures are associated with field
attributes of type DateFormat.Field.
In ISO systems following mapping will be applied:
PlainTime.AM_PM_OF_DAY =>
DateFormat.Field.AM_PMPlainTime.CLOCK_HOUR_OF_AMPM =>
DateFormat.Field.HOUR1PlainTime.CLOCK_HOUR_OF_DAY =>
DateFormat.Field.HOUR_OF_DAY1PlainDate.DAY_OF_MONTH =>
DateFormat.Field.DAY_OF_MONTHPlainDate.DAY_OF_WEEK =>
DateFormat.Field.DAY_OF_WEEKPlainDate.DAY_OF_YEAR =>
DateFormat.Field.DAY_OF_YEARPlainTime.DIGITAL_HOUR_OF_AMPM =>
DateFormat.Field.HOUR1PlainTime.DIGITAL_HOUR_OF_DAY =>
DateFormat.Field.HOUR0PlainTime.MILLI_OF_SECOND =>
DateFormat.Field.MILLISECONDPlainTime.MINUTE_OF_HOUR =>
DateFormat.Field.MINUTEPlainDate.MONTH_AS_NUMBER =>
DateFormat.Field.MONTHPlainDate.MONTH_OF_YEAR =>
DateFormat.Field.MONTHPlainTime.SECOND_OF_MINUTE =>
DateFormat.Field.SECONDPlainDate.WEEKDAY_IN_MONTH =>
DateFormat.Field.DAY_OF_WEEK_IN_MONTHPlainDate.YEAR =>
DateFormat.Field.YEARPlainDate.YEAR_OF_WEEKDATE =>
DateFormat.Field.YEARWeekmodel.boundedWeekOfMonth() =>
DateFormat.Field.WEEK_OF_MONTHWeekmodel.boundedWeekOfYear() =>
DateFormat.Field.WEEK_OF_YEARWeekmodel.weekOfMonth() =>
DateFormat.Field.WEEK_OF_MONTHWeekmodel.weekOfYear() =>
DateFormat.Field.WEEK_OF_YEARWeekmodel.localDayOfWeek() =>
DateFormat.Field.DAY_OF_WEEKChronoEntity.getTimezone() =>
DateFormat.Field.TIME_ZONEChronoHistory.era() =>
DateFormat.Field.ERAChronoHistory.yearOfEra() =>
DateFormat.Field.YEARChronoHistory.month() =>
DateFormat.Field.MONTHChronoHistory.dayOfMonth() =>
DateFormat.Field.DAY_OF_MONTHNote: The returned Format-object is not serializable.
java.text.Format-object which
delegates all formatting and parsing work to this instancepublic static ChronoFormatter<PlainDate> ofDatePattern(String pattern, PatternType type, Locale locale)
Constructs a pattern-based formatter for plain date objects.
pattern - format patterntype - the type of the pattern to be usedlocale - format localeChronoFormatter-instanceIllegalArgumentException - if resolving of pattern failsofPattern(String, PatternType, Locale, Chronology)public static ChronoFormatter<PlainTime> ofTimePattern(String pattern, PatternType type, Locale locale)
Constructs a pattern-based formatter for clock time objects.
pattern - format patterntype - the type of the pattern to be usedlocale - format localeChronoFormatter-instanceIllegalArgumentException - if resolving of pattern failsofPattern(String, PatternType, Locale, Chronology)public static ChronoFormatter<PlainTimestamp> ofTimestampPattern(String pattern, PatternType type, Locale locale)
Constructs a pattern-based formatter for plain timestamps.
pattern - format patterntype - the type of the pattern to be usedlocale - format localeChronoFormatter-instanceIllegalArgumentException - if resolving of pattern failsofPattern(String, PatternType, Locale, Chronology)public static ChronoFormatter<Moment> ofMomentPattern(String pattern, PatternType type, Locale locale, TZID tzid)
Constructs a pattern-based formatter for global timestamp objects.
pattern - format patterntype - the type of the pattern to be usedlocale - format localetzid - timezone idMoment-objects using given locale and timezoneIllegalArgumentException - if resolving of pattern failsofPattern(String, PatternType, Locale, Chronology)public static <T> ChronoFormatter<T> ofPattern(String pattern, PatternType type, Locale locale, Chronology<T> chronology)
Constructs a pattern-based formatter for general chronologies.
If given pattern type is equal to CLDR or derived from CLDR then an additional sanity check will be performed such that following combinations of symbols are excluded:
Note that this check will only be done here but not on builder level (since v4.20). The check does not claim to find all insane combinations of symbols but intends to prevent at least the most wide-spread pattern errors.
T - generic chronological typepattern - format patterntype - the type of the pattern to be usedlocale - format localechronology - chronology with format pattern supportChronoFormatter-instanceIllegalArgumentException - if resolving of pattern failsChronoFormatter.Builder.addPattern(String, PatternType)public static ChronoFormatter<PlainDate> ofDateStyle(DisplayMode style, Locale locale)
Constructs a style-based formatter for plain date objects.
style - format stylelocale - format localeChronoFormatter-instanceCalendarText.patternForDate(DisplayMode, Locale)public static ChronoFormatter<PlainTime> ofTimeStyle(DisplayMode style, Locale locale)
Constructs a style-based formatter for plain date objects.
style - format stylelocale - format localeChronoFormatter-instanceCalendarText.patternForTime(DisplayMode, Locale)public static ChronoFormatter<PlainTimestamp> ofTimestampStyle(DisplayMode dateStyle, DisplayMode timeStyle, Locale locale)
Constructs a style-based formatter for plain timestamps.
dateStyle - format style of date parttimeStyle - format style of time partlocale - format localeChronoFormatter-instanceCalendarText.patternForTimestamp(DisplayMode, DisplayMode, Locale)public static ChronoFormatter<Moment> ofMomentStyle(DisplayMode dateStyle, DisplayMode timeStyle, Locale locale, TZID tzid)
Constructs a style-based formatter for moments.
dateStyle - format style of date parttimeStyle - format style of time partlocale - format localetzid - timezone identifierChronoFormatter-instanceCalendarText.patternForMoment(DisplayMode, DisplayMode, Locale)public static <T extends LocalizedPatternSupport> ChronoFormatter<T> ofStyle(DisplayStyle style, Locale locale, Chronology<T> chronology)
Constructs a style-based formatter for general chronologies.
T - generic chronological typestyle - format stylelocale - format localechronology - chronology with format pattern supportChronoFormatter-instanceUnsupportedOperationException - if given style is not supportedDisplayModepublic static <T extends ChronoEntity<T>> ChronoFormatter.Builder<T> setUp(Class<T> type, Locale locale)
Constructs a builder for creating formatters.
T - generic chronological type (subtype of ChronoEntity)type - reified chronological typelocale - format localeBuilder-instanceIllegalArgumentException - if given chronological type is not
formattable that is if no chronology can be derived from typeChronology.lookup(Class)public static <T> ChronoFormatter.Builder<T> setUp(Chronology<T> chronology, Locale locale)
Constructs a builder for creating formatters.
T - generic chronological type (subtype of ChronoEntity)chronology - formattable chronologylocale - format localeBuilder-instancepublic static <C extends CalendarVariant<C>> ChronoFormatter.Builder<Moment> setUpWithOverride(Locale locale, CalendarFamily<C> overrideCalendar)
Constructs a builder for creating global formatters with usage of given calendar type.
For formatting, it is necessary to set the timezone on the built formatter. For parsing, the calendar variant is necessary.
C - generic calendrical type with variantlocale - format localeoverrideCalendar - formattable calendar chronologyBuilder-instance applicable on Momentpublic static <C extends Calendrical<?,C>> ChronoFormatter.Builder<Moment> setUpWithOverride(Locale locale, Chronology<C> overrideCalendar)
Constructs a builder for creating global formatters with usage of given calendar type.
For formatting, it is necessary to set the timezone on the built formatter.
C - generic calendrical typelocale - format localeoverrideCalendar - formattable calendar chronologyBuilder-instance applicable on Momentpublic boolean equals(Object obj)
Compares the chronologies, default attributes, default values and the internal format structures.
Copyright © 2014–2017. All rights reserved.