Interface ChronoDisplay

All Known Implementing Classes:
AnnualDate, BadiCalendar, CalendarMonth, CalendarQuarter, CalendarVariant, CalendarWeek, CalendarYear, Calendrical, ChineseCalendar, ChronoEntity, CopticCalendar, EastAsianCalendar, EthiopianCalendar, EthiopianTime, FixedCalendarInterval, FrenchRepublicanCalendar, FrenchRepublicanCalendar.Date, GeneralTimestamp, HebrewCalendar, HebrewTime, HijriCalendar, HinduCalendar, HistoricCalendar, IndianCalendar, JapaneseCalendar, JucheCalendar, JulianCalendar, KoreanCalendar, MinguoCalendar, Moment, PersianCalendar, PersianCalendar.Date, PlainDate, PlainTime, PlainTimestamp, SpanOfWeekdays, ThaiSolarCalendar, TimePoint, VietnameseCalendar, ZonalDateTime

public interface ChronoDisplay

Represents a view on a set of chronological elements associated with their temporal values.

A ChronoDisplay serves mainly for formatted output.

Since:
2.0
Author:
Meno Hochschild
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    contains​(ChronoElement<?> element)
    Queries if the value for given chronological element can be accessed via get(element).
    <V> V
    get​(ChronoElement<V> element)
    Returns the partial value associated with given chronological element.
    default int
    Returns the partial value associated with given chronological element.
    <V> V
    getMaximum​(ChronoElement<V> element)
    Yields the maximum value of given chronological element in the current context of this object.
    <V> V
    getMinimum​(ChronoElement<V> element)
    Yields the minimum value of given chronological element in the current context of this object.
    Returns the associated timezone ID for display purposes if available.
    boolean
    Queries if this object contains a timezone for display purposes.
  • Method Details

    • contains

      boolean contains(ChronoElement<?> element)

      Queries if the value for given chronological element can be accessed via get(element).

      If the argument is missing then this method will yield false. Note: Elements which are not registered but define a suitable rule are also accessible.

      Parameters:
      element - chronological element to be asked (optional)
      Returns:
      true if the element is registered or there is an element rule for evaluating the value else false
      See Also:
      get(ChronoElement)
    • get

      <V> V get(ChronoElement<V> element)

      Returns the partial value associated with given chronological element.

      Type Parameters:
      V - generic type of element value
      Parameters:
      element - element which has the value
      Returns:
      associated element value as object (never null)
      Throws:
      ChronoException - if there is no suitable element rule for evaluating the value or if the associated element value is not defined over the complete range of this instance
      See Also:
      contains(ChronoElement)
    • getInt

      default int getInt(ChronoElement<Integer> element)

      Returns the partial value associated with given chronological element.

      Parameters:
      element - element which has the value
      Returns:
      associated element value as int primitive or Integer.MIN_VALUE if not available
      Since:
      3.15/4.12
      See Also:
      get(ChronoElement)
    • getMinimum

      <V> V getMinimum(ChronoElement<V> element)

      Yields the minimum value of given chronological element in the current context of this object.

      The definition of a minimum and a maximum does generally not imply that every intermediate value between minimum and maximum is valid in this context. For example in the timezone Europe/Berlin the hour [T02:00] will be invalid if switching to summer time.

      In most cases the minimum value is not dependent on this context.

      Type Parameters:
      V - generic type of element value
      Parameters:
      element - element whose minimum value is to be evaluated
      Returns:
      minimum maybe context-dependent element value
      Throws:
      ChronoException - if there is no suitable element rule for evaluating the minimum value or if the associated element value is not defined over the complete range of this instance
      See Also:
      ChronoElement.getDefaultMinimum(), getMaximum(ChronoElement)
    • getMaximum

      <V> V getMaximum(ChronoElement<V> element)

      Yields the maximum value of given chronological element in the current context of this object.

      Maximum values are different from minimum case often dependent on the context. An example is the element SECOND_OF_MINUTE whose maximum is normally 59 but can differ in UTC-context with leap seconds. Another more common example is the maximum of the element DAY_OF_MONTH (28-31) which is dependent on the month and year of this context (leap years!).

      Note: In timezone-related timestamps possible offset jumps inducing gaps on the local timeline will be conserved. That means that minimum and maximum do not guarantee a continuum of valid intermediate values.

      Type Parameters:
      V - generic type of element value
      Parameters:
      element - element whose maximum value is to be evaluated
      Returns:
      maximum maybe context-dependent element value
      Throws:
      ChronoException - if there is no suitable element rule for evaluating the maximum value or if the associated element value is not defined over the complete range of this instance
      See Also:
      ChronoElement.getDefaultMaximum(), getMinimum(ChronoElement)
    • hasTimezone

      boolean hasTimezone()

      Queries if this object contains a timezone for display purposes.

      Returns:
      true if a timezone is available and can be achieved with getTimezone() else false
    • getTimezone

      TZID getTimezone()

      Returns the associated timezone ID for display purposes if available.

      Note: Although global types like Moment indeed have a timezone reference (namely UTC+00:00), such types will not support formatted output without explicitly giving a timezone for display purposes. Therefore calling this method on global types will throw an exception. This method is not just about any timezone reference but a timezone designed for display purposes.

      Returns:
      timezone identifier if available
      Throws:
      ChronoException - if the timezone is not available
      See Also:
      hasTimezone()