Package net.time4j.tz

Interface ZoneNameProvider


public interface ZoneNameProvider

SPI interface which encapsulates the timezone name repository.

Implementations are usually stateless and should normally not try to manage a cache. Instead Time4J uses its own cache. The fact that this interface is used per java.util.ServiceLoader requires a concrete implementation to offer a public no-arg constructor.

Since:
3.20/4.16
Author:
Meno Hochschild
See Also:
ServiceLoader
  • Method Summary

    Modifier and Type
    Method
    Description
    getDisplayName​(String zoneID, NameStyle style, Locale locale)
    Returns the name of this timezone suitable for presentation to users in given style and locale.
    getPreferredIDs​(Locale locale, boolean smart)
    Gets a Set of preferred timezone IDs for given ISO-3166-country code.
    default String
    getStdFormatPattern​(boolean zeroOffset, Locale locale)
    Obtains a typical localized format pattern in minute precision.
  • Method Details

    • getPreferredIDs

      Set<String> getPreferredIDs(Locale locale, boolean smart)

      Gets a Set of preferred timezone IDs for given ISO-3166-country code.

      This information is necessary to enable parsing of ambivalent timezone names.

      Parameters:
      locale - ISO-3166-alpha-2-country to be evaluated
      smart - if true then try to select zone ids such that there is only one preferred id per zone name
      Returns:
      unmodifiable set of preferred timezone ids
    • getDisplayName

      String getDisplayName(String zoneID, NameStyle style, Locale locale)

      Returns the name of this timezone suitable for presentation to users in given style and locale.

      The first argument never contains the provider name as prefix. It is instead the part after the "~"-char (if not absent).

      Parameters:
      zoneID - timezone id (i.e. "Europe/London")
      style - name style
      locale - language setting
      Returns:
      localized timezone name for display purposes or empty if not supported
      See Also:
      java.util.TimeZone.getDisplayName(boolean,int,Locale)
    • getStdFormatPattern

      default String getStdFormatPattern(boolean zeroOffset, Locale locale)

      Obtains a typical localized format pattern in minute precision.

      The character "±" represents a localized offset sign. And the double letters "hh" and "mm" represent localized digits of hour respective minute part of the offset. All other characters are to be interpreted as literals. Many locales return the format "GMT±hh:mm" (default).

      Parameters:
      zeroOffset - Is the offset to be formatted equal to UTC?
      locale - language setting
      Returns:
      localized offset pattern
      Since:
      3.23/4.19