T - generic type compatible to ChronoEntitypublic class Chronology<T> extends Object implements ChronoMerger<T>
Represents a system of chronological elements which form any kind of temporal value.
| Modifier and Type | Class and Description |
|---|---|
static class |
Chronology.Builder<T extends ChronoEntity<T>>
Builder for creating a new chronology without any time axis.
|
| Modifier and Type | Method and Description |
|---|---|
T |
createFrom(ChronoEntity<?> entity,
AttributeQuery attributes,
boolean preparsing)
Deprecated.
|
T |
createFrom(ChronoEntity<?> entity,
AttributeQuery attributes,
boolean lenient,
boolean preparsing)
Creates a new entity of type T based on given chronological data.
|
T |
createFrom(TemporalAccessor threeten,
AttributeQuery attributes)
Deprecated.
|
T |
createFrom(TimeSource<?> clock,
AttributeQuery attributes)
Creates a new entity which reflects current time.
|
CalendarSystem<T> |
getCalendarSystem()
Returns the associated calendar system if available.
|
CalendarSystem<T> |
getCalendarSystem(String variant)
Returns the calendar system for given calendar variant if available.
|
Class<T> |
getChronoType()
Returns the chronological type.
|
int |
getDefaultPivotYear()
Determines the default pivot year which might be calendar specific and serves for the
formatting of two-digit-years.
|
StartOfDay |
getDefaultStartOfDay()
Determines the default start of day.
|
List<ChronoExtension> |
getExtensions()
Returns all registered chronological extensions.
|
String |
getFormatPattern(DisplayStyle style,
Locale locale)
Defines a CLDR-compatible localized format pattern.
|
Set<ChronoElement<?>> |
getRegisteredElements()
Returns all registered chronological elements.
|
boolean |
hasCalendarSystem()
Queries if this chronology has a calendar system.
|
boolean |
isRegistered(ChronoElement<?> element)
Queries if given chronological element is registered together
with its element rule.
|
boolean |
isSupported(ChronoElement<?> element)
Queries if given chronological element is supported by this
chronology.
|
static <T extends ChronoEntity<T>> |
lookup(Class<T> chronoType)
Returns a typed singleton per
ChronoEntity-class. |
ChronoDisplay |
preformat(T context,
AttributeQuery attributes)
Transforms the current context/entity into another set of chronological
values which finally shall be formatted using given attributes.
|
Chronology<?> |
preparser()
This method defines a child chronology which can preparse
a chronological text.
|
public Class<T> getChronoType()
Returns the chronological type.
public Set<ChronoElement<?>> getRegisteredElements()
Returns all registered chronological elements.
public boolean isRegistered(ChronoElement<?> element)
Queries if given chronological element is registered together with its element rule.
element - element to be asked (optional)true if registered else falsepublic boolean isSupported(ChronoElement<?> element)
Queries if given chronological element is supported by this chronology.
The element will be supported if it is either registered or defines a suitable element rule for this chronology.
element - element to be asked (optional)true if supported else falsepublic T createFrom(TimeSource<?> clock, AttributeQuery attributes)
ChronoMergerCreates a new entity which reflects current time.
In a date-only chronology this method will create the current date using the necessary timezone contained in given attributes.
createFrom in interface ChronoMerger<T>clock - source for current timeattributes - configuration attributes which might contain
the timezone to translate current time to
local timenull if given data are insufficient@Deprecated public T createFrom(TemporalAccessor threeten, AttributeQuery attributes)
ChronoMergerCreates a new entity of type T based on given chronological data.
The default implementation always returns null so subclasses
with better knowledge about their own state and needs should override it.
createFrom in interface ChronoMerger<T>threeten - object of type TemporalAccessorattributes - configuration attributes given by parsernull if given data are insufficient@Deprecated public T createFrom(ChronoEntity<?> entity, AttributeQuery attributes, boolean preparsing)
ChronoMergerCreates a new entity of type T based on given chronological data.
Typically the method will query the given entity with
different priorities for elements which can compose a new chronological
entity (per group). For example a calendar date can be composed either
by epoch days or the group (year)-(month)-(day-of-month) or the group
(year)-(day-of-year) etc.
A text parser will call this method after having resolved a text
into single chronological elements and values. Implementations should
always validate the parsed values. In case of error, they are free to
either throw an IllegalArgumentException or to generate
and to save an error message by mean of the expression
entity.with(ValidationElement.ERROR_MESSAGE, message.
createFrom in interface ChronoMerger<T>entity - any chronological entity like parsed
elements with their valuesattributes - configuration attributes given by parserpreparsing - preparsing phase active?null if given data are insufficientValidationElement.ERROR_MESSAGEpublic T createFrom(ChronoEntity<?> entity, AttributeQuery attributes, boolean lenient, boolean preparsing)
ChronoMergerCreates a new entity of type T based on given chronological data.
Typically the method will query the given entity with
different priorities for elements which can compose a new chronological
entity (per group). For example a calendar date can be composed either
by epoch days or the group (year)-(month)-(day-of-month) or the group
(year)-(day-of-year) etc.
A text parser will call this method after having resolved a text
into single chronological elements and values. Implementations should
always validate the parsed values. In case of error, they are free to
either throw an IllegalArgumentException or to generate
and to save an error message by mean of the expression
entity.with(ValidationElement.ERROR_MESSAGE, message.
createFrom in interface ChronoMerger<T>entity - any chronological entity like parsed
elements with their valuesattributes - configuration attributes given by parserlenient - controls the leniency how to interprete invalid valuespreparsing - preparsing phase active?null if given data are insufficientValidationElement.ERROR_MESSAGEpublic ChronoDisplay preformat(T context, AttributeQuery attributes)
ChronoMergerTransforms the current context/entity into another set of chronological values which finally shall be formatted using given attributes.
preformat in interface ChronoMerger<T>context - actual chronological context to be formattedattributes - controls attributes during formattingpublic Chronology<?> preparser()
ChronoMergerThis method defines a child chronology which can preparse a chronological text.
preparser in interface ChronoMerger<T>null (default)public String getFormatPattern(DisplayStyle style, Locale locale)
ChronoMergerDefines a CLDR-compatible localized format pattern.
getFormatPattern in interface ChronoMerger<T>style - format stylelocale - language and country settingLocalizedPatternSupportpublic StartOfDay getDefaultStartOfDay()
ChronoMergerDetermines the default start of day.
getDefaultStartOfDay in interface ChronoMerger<T>public int getDefaultPivotYear()
ChronoMergerDetermines the default pivot year which might be calendar specific and serves for the formatting of two-digit-years.
Most calendar chronologies should choose a pivot year 20 years in the future. The standard implementation is based on the gregorian calendar.
getDefaultPivotYear in interface ChronoMerger<T>100)public List<ChronoExtension> getExtensions()
Returns all registered chronological extensions.
This method will be called by format-API in order to collect all extension elements which are relevant for formatting.
public boolean hasCalendarSystem()
Queries if this chronology has a calendar system.
true if this chronology has a calendar system else falsegetCalendarSystem()public CalendarSystem<T> getCalendarSystem()
Returns the associated calendar system if available.
nullChronoException - if the calendar system is unavailable or if there is more than one varianthasCalendarSystem()public CalendarSystem<T> getCalendarSystem(String variant)
Returns the calendar system for given calendar variant if available.
variant - name of calendar variantnullChronoException - if a calendar system is unavailable for given variant (invalid variant name)CalendarVariant.getVariant()public static <T extends ChronoEntity<T>> Chronology<T> lookup(Class<T> chronoType)
Returns a typed singleton per ChronoEntity-class.
T - generic type of time contextchronoType - chronological typenull if not foundCopyright © 2014–2017. All rights reserved.