Interface RelativeTimeProvider

All Superinterfaces:
UnitPatternProvider

public interface RelativeTimeProvider extends UnitPatternProvider

This SPI-interface enables the access to localized unit patterns and is instantiated via a ServiceLoader-mechanism.

If there is no external RelativeTimeProvider then Time4J will use an internal implementation which just offers unit patterns either in english or in scientific notation.

Note: This interface enhances the standard UnitPatternProvider by new methods for short/abbreviated relative times and extra words for "yesterday-today-tomorrow".

Note: All implementations must have a public no-arg constructor.

Since:
3.6/4.4
Author:
Meno Hochschild
See Also:
ServiceLoader
  • Method Details

    • getShortYearPattern

      String getShortYearPattern(Locale lang, boolean future, PluralCategory category)

      Yields the localized unit pattern with short unit name and a placeholder "{0}" for the count of years in the past or future.

      Parameters:
      lang - language setting
      future - use future or past form
      category - plural category
      Returns:
      unit pattern for short years in the past or future
      Throws:
      MissingResourceException - if no pattern was found
      Since:
      3.6/4.4
    • getShortMonthPattern

      String getShortMonthPattern(Locale lang, boolean future, PluralCategory category)

      Yields the localized unit pattern with short unit name and a placeholder "{0}" for the count of months in the past or future.

      Parameters:
      lang - language setting
      future - use future or past form
      category - plural category
      Returns:
      unit pattern for short months in the past or future
      Throws:
      MissingResourceException - if no pattern was found
      Since:
      3.6/4.4
    • getShortWeekPattern

      String getShortWeekPattern(Locale lang, boolean future, PluralCategory category)

      Yields the localized unit pattern with short unit name and a placeholder "{0}" for the count of weeks in the past or future.

      Parameters:
      lang - language setting
      future - use future or past form
      category - plural category
      Returns:
      unit pattern for short weeks in the past or future
      Throws:
      MissingResourceException - if no pattern was found
      Since:
      3.6/4.4
    • getShortDayPattern

      String getShortDayPattern(Locale lang, boolean future, PluralCategory category)

      Yields the localized unit pattern with short unit name and a placeholder "{0}" for the count of days in the past or future.

      Parameters:
      lang - language setting
      future - use future or past form
      category - plural category
      Returns:
      unit pattern for short days in the past or future
      Throws:
      MissingResourceException - if no pattern was found
      Since:
      3.6/4.4
    • getShortHourPattern

      String getShortHourPattern(Locale lang, boolean future, PluralCategory category)

      Yields the localized unit pattern with short unit name and a placeholder "{0}" for the count of hours in the past or future.

      Parameters:
      lang - language setting
      future - use future or past form
      category - plural category
      Returns:
      unit pattern for short hours in the past or future
      Throws:
      MissingResourceException - if no pattern was found
      Since:
      3.6/4.4
    • getShortMinutePattern

      String getShortMinutePattern(Locale lang, boolean future, PluralCategory category)

      Yields the localized unit pattern with short unit name and a placeholder "{0}" for the count of minutes in the past or future.

      Parameters:
      lang - language setting
      future - use future or past form
      category - plural category
      Returns:
      unit pattern for short minutes in the past or future
      Throws:
      MissingResourceException - if no pattern was found
      Since:
      3.6/4.4
    • getShortSecondPattern

      String getShortSecondPattern(Locale lang, boolean future, PluralCategory category)

      Yields the localized unit pattern with short unit name and a placeholder "{0}" for the count of seconds in the past or future.

      Parameters:
      lang - language setting
      future - use future or past form
      category - plural category
      Returns:
      unit pattern for short seconds in the past or future
      Throws:
      MissingResourceException - if no pattern was found
      Since:
      3.6/4.4
    • getYesterdayWord

      String getYesterdayWord(Locale lang)

      Yields the localized word for "yesterday".

      Parameters:
      lang - language setting
      Returns:
      String
      Throws:
      MissingResourceException - if not found
      Since:
      3.6/4.4
    • getTodayWord

      String getTodayWord(Locale lang)

      Yields the localized word for "today".

      Parameters:
      lang - language setting
      Returns:
      String
      Throws:
      MissingResourceException - if not found
      Since:
      3.6/4.4
    • getTomorrowWord

      String getTomorrowWord(Locale lang)

      Yields the localized word for "tomorrow".

      Parameters:
      lang - language setting
      Returns:
      String
      Throws:
      MissingResourceException - if not found
      Since:
      3.6/4.4
    • labelForLast

      default String labelForLast(Weekday weekday, Locale lang)

      Yields the localized word for "last {weekday}".

      Parameters:
      weekday - the last day of week to be queried
      lang - language setting
      Returns:
      String, maybe empty
      Since:
      5.1
    • labelForNext

      default String labelForNext(Weekday weekday, Locale lang)

      Yields the localized word for "next {weekday}".

      Parameters:
      weekday - the next day of week to be queried
      lang - language setting
      Returns:
      String, maybe empty
      Since:
      5.1