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
ConstructorsConstructorDescriptionBridgeChronology(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.intDetermines 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.booleanQueries if this chronology has a calendar system.booleanisSupported(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, lookupMethods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods 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: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.
- Specified by:
createFromin interfaceChronoMerger<S>- Overrides:
createFromin 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
nullif given data are insufficient
-
createFrom
public S createFrom(ChronoEntity<?> entity, AttributeQuery attributes, boolean lenient, boolean preparsing)Description copied from interface:ChronoMergerCreates a new entity of type T based on given chronological data.
Typically the method will query the given
entitywith 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
IllegalArgumentExceptionor to generate and to save an error message by mean of the expressionentity.with(ValidationElement.ERROR_MESSAGE, message.- Specified by:
createFromin interfaceChronoMerger<S>- Overrides:
createFromin 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
nullif given data are insufficient - See Also:
ValidationElement.ERROR_MESSAGE
-
preformat
Description copied from interface:ChronoMergerTransforms the current context/entity into another set of chronological values which finally shall be formatted using given attributes.
- Specified by:
preformatin interfaceChronoMerger<S>- Overrides:
preformatin 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:ChronoMergerThis method defines a child chronology which can preparse a chronological text.
- Specified by:
preparserin interfaceChronoMerger<S>- Overrides:
preparserin classChronology<S>- Returns:
- preparsing chronology or
null(default)
-
getFormatPattern
Not supported for foreign types.
- Specified by:
getFormatPatternin interfaceChronoMerger<S>- Overrides:
getFormatPatternin classChronology<S>- Parameters:
style- format stylelocale- language and country setting- Returns:
- nothing
- Throws:
UnsupportedOperationException- always- See Also:
LocalizedPatternSupport
-
getDefaultStartOfDay
Description copied from interface:ChronoMergerDetermines the default start of day.
- Specified by:
getDefaultStartOfDayin interfaceChronoMerger<S>- Overrides:
getDefaultStartOfDayin classChronology<S>- Returns:
- start of day
-
getDefaultPivotYear
public int getDefaultPivotYear()Description copied from interface: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. If an implementation returns the value
100then the formatting of two-digit-years is effectively switched off.- Specified by:
getDefaultPivotYearin interfaceChronoMerger<S>- Overrides:
getDefaultPivotYearin classChronology<S>- Returns:
- default pivot year (must not be smaller than
100)
-
hasCalendarSystem
public boolean hasCalendarSystem()Description copied from class:ChronologyQueries if this chronology has a calendar system.
- Overrides:
hasCalendarSystemin classChronology<S>- Returns:
trueif this chronology has a calendar system elsefalse- See Also:
Chronology.getCalendarSystem()
-
getCalendarSystem
Description copied from class:ChronologyReturns the associated calendar system if available.
- Overrides:
getCalendarSystemin classChronology<S>- Returns:
- calendar system, not
null - See Also:
Chronology.hasCalendarSystem()
-
getCalendarSystem
Description copied from class:ChronologyReturns the calendar system for given calendar variant if available.
- Overrides:
getCalendarSystemin 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:
isSupportedin classChronology<S>- Parameters:
element- element to be asked (optional)- Returns:
false
-
getRegisteredElements
Description copied from class:ChronologyReturns all registered chronological elements.
- Overrides:
getRegisteredElementsin classChronology<S>- Returns:
- unmodifiable set of elements without duplicates
-
getExtensions
Description copied from class:ChronologyReturns 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:
getExtensionsin classChronology<S>- Returns:
- unmodifiable list of extensions
-