Class Chronology<T>
- Type Parameters:
T
- generic type compatible toChronoEntity
- All Implemented Interfaces:
ChronoMerger<T>
- Direct Known Subclasses:
BridgeChronology
,CalendarFamily
,TimeAxis
Represents a system of chronological elements which form any kind of temporal value.
- Author:
- Meno Hochschild
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Chronology.Builder<T extends ChronoEntity<T>>
Builder for creating a new chronology without any time axis. -
Method Summary
Modifier and TypeMethodDescriptioncreateFrom(TimeSource<?> clock, AttributeQuery attributes)
Creates a new entity which reflects current time.createFrom(ChronoEntity<?> entity, AttributeQuery attributes, boolean lenient, boolean preparsing)
Creates a new entity of type T based on given chronological data.Returns the associated calendar system if available.getCalendarSystem(String variant)
Returns the calendar system for given calendar variant if available.getCalendarSystem(VariantSource variant)
Returns the calendar system for given calendar variant if available.Returns the chronological type.int
Determines the default pivot year which might be calendar specific and serves for the formatting of two-digit-years.Determines the default start of day.Returns all registered chronological extensions.getFormatPattern(FormatStyle style, Locale locale)
Defines a CLDR-compatible localized format pattern.Set<ChronoElement<?>>
Returns all registered chronological elements.boolean
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> Chronology<T>
Returns a typed singleton perChronoEntity
-class.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<?>
This method defines a child chronology which can preparse a chronological text.Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface net.time4j.engine.ChronoMerger
getFormatPattern
-
Method Details
-
getChronoType
Returns the chronological type.
- Returns:
- type of time context
-
getRegisteredElements
Returns all registered chronological elements.
- Returns:
- unmodifiable set of elements without duplicates
-
isRegistered
Queries if given chronological element is registered together with its element rule.
- Parameters:
element
- element to be asked (optional)- Returns:
true
if registered elsefalse
-
isSupported
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.
- Parameters:
element
- element to be asked (optional)- Returns:
true
if supported elsefalse
-
createFrom
Description copied from interface:ChronoMerger
Creates 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.
- Specified by:
createFrom
in interfaceChronoMerger<T>
- Parameters:
clock
- source for current timeattributes
- configuration attributes which might contain the timezone to translate current time to local time- Returns:
- new time context or
null
if given data are insufficient
-
createFrom
public T createFrom(ChronoEntity<?> entity, AttributeQuery attributes, boolean lenient, boolean preparsing)Description copied from interface:ChronoMerger
Creates 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 expressionentity.with(ValidationElement.ERROR_MESSAGE, message
.- Specified by:
createFrom
in interfaceChronoMerger<T>
- Parameters:
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?- Returns:
- new time context or
null
if given data are insufficient - See Also:
ValidationElement.ERROR_MESSAGE
-
preformat
Description copied from interface:ChronoMerger
Transforms the current context/entity into another set of chronological values which finally shall be formatted using given attributes.
- Specified by:
preformat
in interfaceChronoMerger<T>
- Parameters:
context
- actual chronological context to be formattedattributes
- controls attributes during formatting- Returns:
- replacement entity which will finally be used for formatting
-
preparser
Description copied from interface:ChronoMerger
This method defines a child chronology which can preparse a chronological text.
- Specified by:
preparser
in interfaceChronoMerger<T>
- Returns:
- preparsing chronology or
null
(default)
-
getFormatPattern
Description copied from interface:ChronoMerger
Defines a CLDR-compatible localized format pattern.
The default implementation always throws an
UnsupportedOperationException
.- Specified by:
getFormatPattern
in interfaceChronoMerger<T>
- Parameters:
style
- format stylelocale
- language and country setting- Returns:
- localized format pattern
- See Also:
LocalizedPatternSupport
-
getDefaultStartOfDay
Description copied from interface:ChronoMerger
Determines the default start of day.
- Specified by:
getDefaultStartOfDay
in interfaceChronoMerger<T>
- Returns:
- start of day
-
getDefaultPivotYear
public int getDefaultPivotYear()Description copied from interface:ChronoMerger
Determines 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. If an implementation returns the value
100
then the formatting of two-digit-years is effectively switched off.- Specified by:
getDefaultPivotYear
in interfaceChronoMerger<T>
- Returns:
- default pivot year (must not be smaller than
100
)
-
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.
- Returns:
- unmodifiable list of extensions
-
hasCalendarSystem
public boolean hasCalendarSystem()Queries if this chronology has a calendar system.
- Returns:
true
if this chronology has a calendar system elsefalse
- See Also:
getCalendarSystem()
-
getCalendarSystem
Returns the associated calendar system if available.
- Returns:
- calendar system, not
null
- Throws:
ChronoException
- if the calendar system is unavailable or if there is more than one variant- See Also:
hasCalendarSystem()
-
getCalendarSystem
Returns the calendar system for given calendar variant if available.
- Parameters:
variant
- name of calendar variant- Returns:
- calendar system, not
null
- Throws:
ChronoException
- if a calendar system is unavailable for given variant (invalid variant name)- Since:
- 3.4/4.3
- See Also:
VariantSource.getVariant()
-
getCalendarSystem
Returns the calendar system for given calendar variant if available.
- Parameters:
variant
- name of calendar variant- Returns:
- calendar system, not
null
- Throws:
ChronoException
- if a calendar system is unavailable for given variant (invalid variant name)- Since:
- 5.0
-
lookup
Returns a typed singleton per
ChronoEntity
-class.- Type Parameters:
T
- generic type of time context- Parameters:
chronoType
- chronological type- Returns:
- chronology or
null
if not found
-