Interface UnitPatternProvider

All Known Subinterfaces:
RelativeTimeProvider

public interface UnitPatternProvider

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

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

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

Since:
1.2
Author:
Meno Hochschild
See Also:
ServiceLoader
  • Method Details

    • getYearPattern

      String getYearPattern(Locale lang, TextWidth width, PluralCategory category)

      Yields the localized unit pattern with unit name and a placeholder "{0}" for the count of years.

      Parameters:
      lang - language setting
      width - text width (ABBREVIATED as synonym for SHORT)
      category - plural category
      Returns:
      unit pattern for years
      Throws:
      MissingResourceException - if no pattern was found
      Since:
      1.2
    • getMonthPattern

      String getMonthPattern(Locale lang, TextWidth width, PluralCategory category)

      Yields the localized unit pattern with unit name and a placeholder "{0}" for the count of months.

      Parameters:
      lang - language setting
      width - text width (ABBREVIATED as synonym for SHORT)
      category - plural category
      Returns:
      unit pattern for months
      Throws:
      MissingResourceException - if no pattern was found
      Since:
      1.2
    • getWeekPattern

      String getWeekPattern(Locale lang, TextWidth width, PluralCategory category)

      Yields the localized unit pattern with unit name and a placeholder "{0}" for the count of weeks.

      Parameters:
      lang - language setting
      width - text width (ABBREVIATED as synonym for SHORT)
      category - plural category
      Returns:
      unit pattern for weeks
      Throws:
      MissingResourceException - if no pattern was found
      Since:
      1.2
    • getDayPattern

      String getDayPattern(Locale lang, TextWidth width, PluralCategory category)

      Yields the localized unit pattern with unit name and a placeholder "{0}" for the count of days.

      Parameters:
      lang - language setting
      width - text width (ABBREVIATED as synonym for SHORT)
      category - plural category
      Returns:
      unit pattern for days
      Throws:
      MissingResourceException - if no pattern was found
      Since:
      1.2
    • getHourPattern

      String getHourPattern(Locale lang, TextWidth width, PluralCategory category)

      Yields the localized unit pattern with unit name and a placeholder "{0}" for the count of hours.

      Parameters:
      lang - language setting
      width - text width (ABBREVIATED as synonym for SHORT)
      category - plural category
      Returns:
      unit pattern for hours
      Throws:
      MissingResourceException - if no pattern was found
      Since:
      1.2
    • getMinutePattern

      String getMinutePattern(Locale lang, TextWidth width, PluralCategory category)

      Yields the localized unit pattern with unit name and a placeholder "{0}" for the count of minutes.

      Parameters:
      lang - language setting
      width - text width (ABBREVIATED as synonym for SHORT)
      category - plural category
      Returns:
      unit pattern for minutes
      Throws:
      MissingResourceException - if no pattern was found
      Since:
      1.2
    • getSecondPattern

      String getSecondPattern(Locale lang, TextWidth width, PluralCategory category)

      Yields the localized unit pattern with unit name and a placeholder "{0}" for the count of seconds.

      Parameters:
      lang - language setting
      width - text width (ABBREVIATED as synonym for SHORT)
      category - plural category
      Returns:
      unit pattern for seconds
      Throws:
      MissingResourceException - if no pattern was found
      Since:
      1.2
    • getMilliPattern

      String getMilliPattern(Locale lang, TextWidth width, PluralCategory category)

      Yields the localized unit pattern with unit name and a placeholder "{0}" for the count of milliseconds.

      Parameters:
      lang - language setting
      width - text width (ABBREVIATED as synonym for SHORT)
      category - plural category
      Returns:
      unit pattern for milliseconds
      Throws:
      MissingResourceException - if no pattern was found
      Since:
      1.2
    • getMicroPattern

      String getMicroPattern(Locale lang, TextWidth width, PluralCategory category)

      Yields the localized unit pattern with unit name and a placeholder "{0}" for the count of microseconds.

      Parameters:
      lang - language setting
      width - text width (ABBREVIATED as synonym for SHORT)
      category - plural category
      Returns:
      unit pattern for microseconds
      Throws:
      MissingResourceException - if no pattern was found
      Since:
      1.2
    • getNanoPattern

      String getNanoPattern(Locale lang, TextWidth width, PluralCategory category)

      Yields the localized unit pattern with unit name and a placeholder "{0}" for the count of nanoseconds.

      Parameters:
      lang - language setting
      width - text width (ABBREVIATED as synonym for SHORT)
      category - plural category
      Returns:
      unit pattern for nanoseconds
      Throws:
      MissingResourceException - if no pattern was found
      Since:
      1.2
    • getYearPattern

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

      Yields the localized unit pattern with 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 years in the past or future
      Throws:
      MissingResourceException - if no pattern was found
      Since:
      1.2
    • getMonthPattern

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

      Yields the localized unit pattern with 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 months in the past or future
      Throws:
      MissingResourceException - if no pattern was found
      Since:
      1.2
    • getWeekPattern

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

      Yields the localized unit pattern with 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 weeks in the past or future
      Throws:
      MissingResourceException - if no pattern was found
      Since:
      1.2
    • getDayPattern

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

      Yields the localized unit pattern with 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 days in the past or future
      Throws:
      MissingResourceException - if no pattern was found
      Since:
      1.2
    • getHourPattern

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

      Yields the localized unit pattern with 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 hours in the past or future
      Throws:
      MissingResourceException - if no pattern was found
      Since:
      1.2
    • getMinutePattern

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

      Yields the localized unit pattern with 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 minutes in the past or future
      Throws:
      MissingResourceException - if no pattern was found
      Since:
      1.2
    • getSecondPattern

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

      Yields the localized unit pattern with 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 seconds in the past or future
      Throws:
      MissingResourceException - if no pattern was found
      Since:
      1.2
    • getNowWord

      String getNowWord(Locale lang)

      Yields the localized word for the current time (now).

      Parameters:
      lang - language setting
      Returns:
      String
      Throws:
      MissingResourceException - if not found
      Since:
      1.2
    • getListPattern

      String getListPattern(Locale lang, TextWidth width, int size)

      Constructs a localized list pattern suitable for the use in MessageFormat.format(String, Object[]).

      Parameters:
      lang - language setting
      width - text width (ABBREVIATED as synonym for SHORT)
      size - count of list items
      Returns:
      message format pattern with placeholders {0}, {1}, ..., {x}, ...
      Throws:
      IllegalArgumentException - if size is smaller than 2
      MissingResourceException - if no pattern was found
      Since:
      1.2