Class RelativeDate

  • All Implemented Interfaces:
    java.lang.Comparable<RelativeDate>

    public class RelativeDate
    extends java.lang.Object
    implements java.lang.Comparable<RelativeDate>
    RelativeDate - models the specification of a relative date. The following types of dates can be modelled:
    • First DOW of the month, where DOW is the "day of week". eg. "first Sunday of the month"
    • Last DOW of the month. eg. "last Sunday of the month"
    • First DOW on or after date. eg. "First Sunday on or after the 8th of the month"
    • First DOW on or before date. eg. "First Sunday on or before the 25th of the month"
    • A specific day of the month. eg. "May 8".
    • Field Detail

      • months

        protected static java.util.HashMap<java.lang.String,​java.lang.Integer> months
      • weekDays

        protected static java.util.HashMap<java.lang.String,​java.lang.Integer> weekDays
      • year

        protected int year
      • month

        protected int month
      • dayOfWeek

        protected int dayOfWeek
      • dayOfMonth

        protected int dayOfMonth
      • hour

        protected int hour
      • minute

        protected int minute
      • second

        protected int second
      • zoneChar

        protected char zoneChar
      • logger

        protected org.apache.log4j.Logger logger
    • Constructor Detail

      • RelativeDate

        public RelativeDate()
      • RelativeDate

        public RelativeDate​(RelativeDate.StartRule rule,
                            int dayOfWeek,
                            int dayOfMonth,
                            int month)
    • Method Detail

      • parse

        public void parse​(java.lang.String[] fields,
                          int startIndex)
      • offsetToWallTime

        public void offsetToWallTime​(int offsetHour,
                                     int offsetMinute,
                                     int savingsHour,
                                     int savingsMinute)
        If the current relative date has a zone char and that zone char is not "w", then the transition time was given as a standard time or as a UTC time instead of wall time. Either way, ilib needs to have the wall time in order to do the correct rule start calculations. This method converts non-wall-time relative dates to a wall time.
        Parameters:
        offset - the offset from UTC for this rule in hours
        savings - the DST savings for this rule in hours
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • getYear

        public int getYear()
        Returns:
        the year
      • setYear

        public void setYear​(int year)
        Parameters:
        year - the year to set
      • getMonth

        public int getMonth()
        Returns:
        the month
      • setMonth

        public void setMonth​(int month)
        Parameters:
        month - the month to set
      • getDayOfWeek

        public int getDayOfWeek()
        Returns:
        the dayOfWeek
      • setDayOfWeek

        public void setDayOfWeek​(int dayOfWeek)
        Parameters:
        dayOfWeek - the dayOfWeek to set
      • getDayOfMonth

        public int getDayOfMonth()
        Returns:
        the dayOfMonth
      • setDayOfMonth

        public void setDayOfMonth​(int dayOfMonth)
        Parameters:
        dayOfMonth - the dayOfMonth to set
      • getHour

        public int getHour()
        Returns:
        the hour
      • setHour

        public void setHour​(int hour)
        Parameters:
        hour - the hour to set
      • getMinute

        public int getMinute()
        Returns:
        the minute
      • setMinute

        public void setMinute​(int minute)
        Parameters:
        minute - the minute to set
      • getSecond

        public int getSecond()
        Returns:
        the second
      • setSecond

        public void setSecond​(int second)
        Parameters:
        second - the second to set
      • getZoneChar

        public char getZoneChar()
        Returns:
        the zoneChar
      • setZoneChar

        public void setZoneChar​(char zoneChar)
        Parameters:
        zoneChar - the zoneChar to set
      • compareTo

        public int compareTo​(RelativeDate other)
        Specified by:
        compareTo in interface java.lang.Comparable<RelativeDate>
      • addJson

        public org.json.JSONObject addJson​(org.json.JSONObject json)
                                    throws org.json.JSONException
        Throws:
        org.json.JSONException
      • clone

        public RelativeDate clone()
        Overrides:
        clone in class java.lang.Object