Class TimeRule


  • public final class TimeRule
    extends NativeBase

    Used to indicate a time period of one or more intervals in GDF specification. For example: -*(M3f21h2){M9}(M11f12h2){-M9}+(h15){h2}(h20){h2}, which represents: March 2nd Sunday 02h:00m for 9 months ONLY DURING November 1st Sunday 02h:00m from 9 months ago BUT NOT from 15:00 to 17:00 OR 20:00 to 22:00

    The operator * represents reccuring occurrence, + represents a logical OR operation and - represents exclusion meaning, BUT NOT operations.

    This example string represents a time period that meets the following criteria:

    • M3f21h2: M3 denotes third month of the year, i.e. March, f2 stands for the second Sunday of the month (as "f" might indicate "first", "second", "third", etc.), 1 stands for the day of the week (1...7, Day of week, Sunday = day 1), and h2 represents the hour of the day (02:00) in 24 hour format.
    • {M9}: This denotes "for 9 months", with "M9" standing for nine months. The brackets {} indicate a duration.
    • M11f12h2: M11 denotes 11th month of the year, i.e. November, f1 stands for the first Monday of the month, 2 stands for the day of the week (1...7, Day of week, Monday = day 2), and h2 represents the hour of the day (02:00) in 24 hour format.
    • {-M9}: This denotes "9 months ago from the current stated time", with "-M9" standing for nine months in the past.
    • (h15){h2}(h20){h2}: 15:00 to 17:00 OR 20:00 to 22:00 The brackets {} denotes duration, and the negative sign - represents a past duration.

    Note: The time period is a logical AND (&&) combination of two components or points in time and it only applies if a point in time is in both components.

    For more advanced examples of TimeRule see here.

    • Constructor Summary

      Constructors 
      Constructor Description
      TimeRule​(java.lang.String timeRule, int timeZoneOffsetSeconds, java.lang.String dstSpec)
      Creates a new instance of this class.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean appliesTo​(java.util.Date dateTime)  
      boolean equals​(java.lang.Object rhs)  
      java.lang.String getDstSpec()
      Gets the value of day saving time specification, as a string in ISO 14825 format, for the location where the time rule applies.
      java.lang.String getTimeRuleString()
      Gets the value of time rule as a string in ISO 14825 format.
      int getTimeZoneOffsetSeconds()
      Gets the value of time zone offset in seconds for the location where the time rule applies.
      int hashCode()  
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • TimeRule

        public TimeRule​(@NonNull
                        java.lang.String timeRule,
                        int timeZoneOffsetSeconds,
                        @NonNull
                        java.lang.String dstSpec)

        Creates a new instance of this class.

        Parameters:
        timeRule -

        The time rule as a string in ISO 14825 format.

        timeZoneOffsetSeconds -

        The time zone offset in seconds for the location where the time rule applies.

        dstSpec -

        Day saving time specification, as a string in ISO 14825 format, for the location where the time rule applies.

    • Method Detail

      • equals

        public boolean equals​(java.lang.Object rhs)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • appliesTo

        public boolean appliesTo​(@NonNull
                                 java.util.Date dateTime)
        Parameters:
        dateTime -

        date and time that should be used for rule verification.

        Returns:

        true if the time domain rules applies to the given date and time., false - otherwise.

      • getTimeRuleString

        @NonNull
        public java.lang.String getTimeRuleString()

        Gets the value of time rule as a string in ISO 14825 format.

        Returns:

        The time rule as a string in ISO 14825 format.

      • getTimeZoneOffsetSeconds

        public int getTimeZoneOffsetSeconds()

        Gets the value of time zone offset in seconds for the location where the time rule applies.

        Returns:

        The time zone offset in seconds for the location where the time rule applies.

      • getDstSpec

        @NonNull
        public java.lang.String getDstSpec()

        Gets the value of day saving time specification, as a string in ISO 14825 format, for the location where the time rule applies.

        Returns:

        Day saving time specification, as a string in ISO 14825 format, for the location where the time rule applies.