Class AnnualTimeZoneRule

  • All Implemented Interfaces:
    java.io.Serializable

    public class AnnualTimeZoneRule
    extends TimeZoneRule
    AnnualTimeZoneRule is a class used for representing a time zone rule which takes effect annually. Years used in this class are all Gregorian calendar years.
    See Also:
    Serialized Form
    • Constructor Summary

      Constructors 
      Constructor Description
      AnnualTimeZoneRule​(java.lang.String name, int rawOffset, int dstSavings, DateTimeRule dateTimeRule, int startYear, int endYear)
      Constructs a AnnualTimeZoneRule with the name, the GMT offset of its standard time, the amount of daylight saving offset adjustment, the annual start time rule and the start/until years.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int getEndYear()
      Gets the end year when this rule takes effect.
      java.util.Date getFinalStart​(int prevRawOffset, int prevDSTSavings)
      Gets the final time when this rule takes effect.
      java.util.Date getFirstStart​(int prevRawOffset, int prevDSTSavings)
      Gets the very first time when this rule takes effect.
      java.util.Date getNextStart​(long base, int prevRawOffset, int prevDSTSavings, boolean inclusive)
      Gets the first time when this rule takes effect after the specified time.
      java.util.Date getPreviousStart​(long base, int prevRawOffset, int prevDSTSavings, boolean inclusive)
      Gets the most recent time when this rule takes effect before the specified time.
      DateTimeRule getRule()
      Gets the start date/time rule associated used by this rule.
      java.util.Date getStartInYear​(int year, int prevRawOffset, int prevDSTSavings)
      Gets the time when this rule takes effect in the given year.
      int getStartYear()
      Gets the first year when this rule takes effect.
      boolean isEquivalentTo​(TimeZoneRule other)
      Returns if this rule represents the same rule and offsets as another.
      boolean isTransitionRule()
      Returns if this TimeZoneRule has one or more start times.
      java.lang.String toString()
      Returns a String representation of this AnnualTimeZoneRule object.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • MAX_YEAR

        public static final int MAX_YEAR
        The constant representing the maximum year used for designating a rule is permanent.
        See Also:
        Constant Field Values
      • startYear

        private final int startYear
      • endYear

        private final int endYear
    • Constructor Detail

      • AnnualTimeZoneRule

        public AnnualTimeZoneRule​(java.lang.String name,
                                  int rawOffset,
                                  int dstSavings,
                                  DateTimeRule dateTimeRule,
                                  int startYear,
                                  int endYear)
        Constructs a AnnualTimeZoneRule with the name, the GMT offset of its standard time, the amount of daylight saving offset adjustment, the annual start time rule and the start/until years.
        Parameters:
        name - The time zone name.
        rawOffset - The GMT offset of its standard time in milliseconds.
        dstSavings - The amount of daylight saving offset adjustment in milliseconds. If this ia a rule for standard time, the value of this argument is 0.
        dateTimeRule - The start date/time rule repeated annually.
        startYear - The first year when this rule takes effect.
        endYear - The last year when this rule takes effect. If this rule is effective forever in future, specify MAX_YEAR.
    • Method Detail

      • getRule

        public DateTimeRule getRule()
        Gets the start date/time rule associated used by this rule.
        Returns:
        An AnnualDateTimeRule which represents the start date/time rule used by this time zone rule.
      • getStartYear

        public int getStartYear()
        Gets the first year when this rule takes effect.
        Returns:
        The start year of this rule. The year is in Gregorian calendar with 0 == 1 BCE, -1 == 2 BCE, etc.
      • getEndYear

        public int getEndYear()
        Gets the end year when this rule takes effect.
        Returns:
        The end year of this rule (inclusive). The year is in Gregorian calendar with 0 == 1 BCE, -1 == 2 BCE, etc.
      • getStartInYear

        public java.util.Date getStartInYear​(int year,
                                             int prevRawOffset,
                                             int prevDSTSavings)
        Gets the time when this rule takes effect in the given year.
        Parameters:
        year - The Gregorian year, with 0 == 1 BCE, -1 == 2 BCE, etc.
        prevRawOffset - The standard time offset from UTC before this rule takes effect in milliseconds.
        prevDSTSavings - The amount of daylight saving offset from the standard time.
        Returns:
        The time when this rule takes effect in the year, or null if this rule is not applicable in the year.
      • getFirstStart

        public java.util.Date getFirstStart​(int prevRawOffset,
                                            int prevDSTSavings)
        Gets the very first time when this rule takes effect.
        Specified by:
        getFirstStart in class TimeZoneRule
        Parameters:
        prevRawOffset - The standard time offset from UTC before this rule takes effect in milliseconds.
        prevDSTSavings - The amount of daylight saving offset from the standard time.
        Returns:
        The very first time when this rule takes effect.
      • getFinalStart

        public java.util.Date getFinalStart​(int prevRawOffset,
                                            int prevDSTSavings)
        Gets the final time when this rule takes effect.
        Specified by:
        getFinalStart in class TimeZoneRule
        Parameters:
        prevRawOffset - The standard time offset from UTC before this rule takes effect in milliseconds.
        prevDSTSavings - The amount of daylight saving offset from the standard time.
        Returns:
        The very last time when this rule takes effect, or null if this rule is applied for future dates infinitely.
      • getNextStart

        public java.util.Date getNextStart​(long base,
                                           int prevRawOffset,
                                           int prevDSTSavings,
                                           boolean inclusive)
        Gets the first time when this rule takes effect after the specified time.
        Specified by:
        getNextStart in class TimeZoneRule
        Parameters:
        base - The first time after this time is returned.
        prevRawOffset - The standard time offset from UTC before this rule takes effect in milliseconds.
        prevDSTSavings - The amount of daylight saving offset from the standard time.
        inclusive - Whether the base time is inclusive or not.
        Returns:
        The first time when this rule takes effect after the specified time, or null when this rule never takes effect after the specified time.
      • getPreviousStart

        public java.util.Date getPreviousStart​(long base,
                                               int prevRawOffset,
                                               int prevDSTSavings,
                                               boolean inclusive)
        Gets the most recent time when this rule takes effect before the specified time.
        Specified by:
        getPreviousStart in class TimeZoneRule
        Parameters:
        base - The most recent time when this rule takes effect before this time is returned.
        prevRawOffset - The standard time offset from UTC before this rule takes effect in milliseconds.
        prevDSTSavings - The amount of daylight saving offset from the standard time.
        inclusive - Whether the base time is inclusive or not.
        Returns:
        The most recent time when this rule takes effect before the specified time, or null when this rule never takes effect before the specified time.
      • isEquivalentTo

        public boolean isEquivalentTo​(TimeZoneRule other)
        Returns if this rule represents the same rule and offsets as another. When two TimeZoneRule objects differ only its names, this method returns true.
        Overrides:
        isEquivalentTo in class TimeZoneRule
        Parameters:
        other - The TimeZoneRule object to be compared with.
        Returns:
        true if the other TimeZoneRule is the same as this one.
      • isTransitionRule

        public boolean isTransitionRule()
        Returns if this TimeZoneRule has one or more start times.

        Note: This method in AnnualTimeZoneRule always returns true.
        Specified by:
        isTransitionRule in class TimeZoneRule
        Returns:
        true if this TimeZoneRule has one or more start times.
      • toString

        public java.lang.String toString()
        Returns a String representation of this AnnualTimeZoneRule object. This method is used for debugging purpose only. The string representation can be changed in future version of ICU without any notice.
        Overrides:
        toString in class TimeZoneRule