Class EasterRule

  • All Implemented Interfaces:
    DateRule

    class EasterRule
    extends java.lang.Object
    implements DateRule
    • Constructor Summary

      Constructors 
      Constructor Description
      EasterRule​(int daysAfterEaster, boolean isOrthodox)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      private java.util.Date computeInYear​(java.util.Date date, GregorianCalendar cal)
      Compute the month and date on which this holiday falls in the year containing the date "date".
      private java.util.Date doFirstBetween​(java.util.Date start, java.util.Date end)  
      java.util.Date firstAfter​(java.util.Date start)
      Return the first occurrence of this rule on or after the given date
      java.util.Date firstBetween​(java.util.Date start, java.util.Date end)
      Return the first occurrence of this rule on or after the given start date and before the given end date.
      boolean isBetween​(java.util.Date start, java.util.Date end)
      Return true if Easter occurs between the two dates given
      boolean isOn​(java.util.Date date)
      Return true if the given Date is on the same day as Easter
      • Methods inherited from class java.lang.Object

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

      • daysAfterEaster

        private int daysAfterEaster
    • Constructor Detail

      • EasterRule

        public EasterRule​(int daysAfterEaster,
                          boolean isOrthodox)
    • Method Detail

      • firstAfter

        public java.util.Date firstAfter​(java.util.Date start)
        Return the first occurrence of this rule on or after the given date
        Specified by:
        firstAfter in interface DateRule
        Parameters:
        start - Only occurrances on or after this date are returned.
        Returns:
        The date on which this event occurs, or null if it does not occur on or after the start date.
        See Also:
        DateRule.firstBetween(java.util.Date, java.util.Date)
      • firstBetween

        public java.util.Date firstBetween​(java.util.Date start,
                                           java.util.Date end)
        Return the first occurrence of this rule on or after the given start date and before the given end date.
        Specified by:
        firstBetween in interface DateRule
        Parameters:
        start - Only occurrances on or after this date are returned.
        end - Only occurrances before this date are returned.
        Returns:
        The date on which this event occurs, or null if it does not occur between the start and end dates.
        See Also:
        DateRule.firstAfter(java.util.Date)
      • isOn

        public boolean isOn​(java.util.Date date)
        Return true if the given Date is on the same day as Easter
        Specified by:
        isOn in interface DateRule
        Parameters:
        date - The date to check.
        Returns:
        true if this event occurs on the given date.
      • isBetween

        public boolean isBetween​(java.util.Date start,
                                 java.util.Date end)
        Return true if Easter occurs between the two dates given
        Specified by:
        isBetween in interface DateRule
      • doFirstBetween

        private java.util.Date doFirstBetween​(java.util.Date start,
                                              java.util.Date end)
      • computeInYear

        private java.util.Date computeInYear​(java.util.Date date,
                                             GregorianCalendar cal)
        Compute the month and date on which this holiday falls in the year containing the date "date". First figure out which date Easter lands on in this year, and then add the offset for this holiday to get the right date.

        The algorithm here is taken from the Calendar FAQ.