Class ZoneRulesProvider

java.lang.Object
dev.gmitch215.bytebox.time.ZoneRulesProvider

public class ZoneRulesProvider extends Object
Where java.time gets its timezone rules.

This stands in for the provider a java.time implementation reads a compiled copy of the timezone database through. The isolate already carries that database behind Intl, so the rules are derived from what it reports; see IntlZoneRules. What that saves is the 108 KB the compiled copy occupies plus the reader for it, neither of which becomes reachable.

An identifier is accepted if the platform accepts it, which includes the aliases a canonical list leaves out: US/Eastern resolves even though getAvailableZoneIds() does not name it.

Since:
1.0.0
  • Constructor Details

    • ZoneRulesProvider

      protected ZoneRulesProvider()
      Only ever reached by the compiler, when a class it rewrote declares this as its supertype.
  • Method Details

    • getAvailableZoneIds

      public static Set<String> getAvailableZoneIds()
      Returns every identifier the platform names, which excludes aliases it nonetheless accepts.
      Returns:
      every identifier the platform names, which excludes aliases it nonetheless accepts
    • getRules

      public static ZoneRules getRules(String zoneId, boolean forCaching)
      The rules for an identifier.
      Parameters:
      zoneId - an IANA identifier, such as Europe/London
      forCaching - whether the caller intends to hold on to the result, which makes no difference here because the platform's database changes only when the platform does
      Returns:
      the rules
      Throws:
      ZoneRulesException - when the platform does not recognise the identifier
    • getVersions

      public static NavigableMap<String,ZoneRules> getVersions(String zoneId)
      The one version of the rules there is.
      Parameters:
      zoneId - an IANA identifier
      Returns:
      a map holding the single version the platform carries
      Throws:
      ZoneRulesException - when the platform does not recognise the identifier
    • refresh

      public static boolean refresh()
      Returns false, because the platform's database changes only when the platform does.
      Returns:
      false, because the platform's database changes only when the platform does