Class BridgeChronology<S,T extends ChronoEntity<T>>
- Type Parameters:
S
- generic type of foreign temporal typeT
- generic type compatible toChronoEntity
- All Implemented Interfaces:
ChronoMerger<S>
Represents a foreign chronology which delegates formatting and parsing to a chronology in Time4J.
A ChronoFormatter
can be created by help of this chronology such that the formatter can be
adjusted to any foreign type without external conversion.
Important to know: This chronology does not register any elements and is also not registered itself
so Chronology.lookup(...)
will inevitably fail to find this chronology.
- Since:
- 3.24/4.20
- Author:
- Meno Hochschild
- See Also:
TemporalType
-
Nested Class Summary
Nested classes/interfaces inherited from class net.time4j.engine.Chronology
Chronology.Builder<T extends ChronoEntity<T>>
-
Constructor Summary
ConstructorDescriptionBridgeChronology(Converter<S,T> converter, Chronology<T> delegate)
Constructs a new instance. -
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.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)
Not supported for foreign types.Set<ChronoElement<?>>
Returns all registered chronological elements.boolean
Queries if this chronology has a calendar system.boolean
isSupported(ChronoElement<?> element)
This chronology does not itself support any elements.preformat(S 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 net.time4j.engine.Chronology
getCalendarSystem, getChronoType, isRegistered, lookup
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
-
Constructor Details
-
BridgeChronology
Constructs a new instance.
- Parameters:
converter
- used in any type conversion, should be statelessdelegate
- delegate chronology in Time4J
-
-
Method Details
-
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<S>
- Overrides:
createFrom
in classChronology<S>
- 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 S 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<S>
- Overrides:
createFrom
in classChronology<S>
- 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<S>
- Overrides:
preformat
in classChronology<S>
- 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<S>
- Overrides:
preparser
in classChronology<S>
- Returns:
- preparsing chronology or
null
(default)
-
getFormatPattern
Not supported for foreign types.
- Specified by:
getFormatPattern
in interfaceChronoMerger<S>
- Overrides:
getFormatPattern
in classChronology<S>
- Parameters:
style
- format stylelocale
- language and country setting- Returns:
- nothing
- Throws:
UnsupportedOperationException
- always- See Also:
LocalizedPatternSupport
-
getDefaultStartOfDay
Description copied from interface:ChronoMerger
Determines the default start of day.
- Specified by:
getDefaultStartOfDay
in interfaceChronoMerger<S>
- Overrides:
getDefaultStartOfDay
in classChronology<S>
- 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<S>
- Overrides:
getDefaultPivotYear
in classChronology<S>
- Returns:
- default pivot year (must not be smaller than
100
)
-
hasCalendarSystem
public boolean hasCalendarSystem()Description copied from class:Chronology
Queries if this chronology has a calendar system.
- Overrides:
hasCalendarSystem
in classChronology<S>
- Returns:
true
if this chronology has a calendar system elsefalse
- See Also:
Chronology.getCalendarSystem()
-
getCalendarSystem
Description copied from class:Chronology
Returns the associated calendar system if available.
- Overrides:
getCalendarSystem
in classChronology<S>
- Returns:
- calendar system, not
null
- See Also:
Chronology.hasCalendarSystem()
-
getCalendarSystem
Description copied from class:Chronology
Returns the calendar system for given calendar variant if available.
- Overrides:
getCalendarSystem
in classChronology<S>
- Parameters:
variant
- name of calendar variant- Returns:
- calendar system, not
null
- See Also:
VariantSource.getVariant()
-
isSupported
This chronology does not itself support any elements.
Only its delegate chronology might support given element.
- Overrides:
isSupported
in classChronology<S>
- Parameters:
element
- element to be asked (optional)- Returns:
false
-
getRegisteredElements
Description copied from class:Chronology
Returns all registered chronological elements.
- Overrides:
getRegisteredElements
in classChronology<S>
- Returns:
- unmodifiable set of elements without duplicates
-
getExtensions
Description copied from class:Chronology
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.
- Overrides:
getExtensions
in classChronology<S>
- Returns:
- unmodifiable list of extensions
-