All Implemented Interfaces:
Comparable<ByRule<List<ByDay.ByDayPair>>>, ByRule<List<ByDay.ByDayPair>>, RRulePart<List<ByDay.ByDayPair>>, VChild, VElement

public class ByDay extends ByRuleAbstract<ByDay.ByDayPair,ByDay>
BYDAY from RFC 5545, iCalendar 3.3.10, page 40 The BYDAY rule part specifies a COMMA-separated list of days of the week; SU indicates Sunday; MO indicates Monday; TU indicates Tuesday; WE indicates Wednesday; TH indicates Thursday; FR indicates Friday; and SA indicates Saturday. Each BYDAY value can also be preceded by a positive (+n) or negative (-n) integer. If present, this indicates the nth occurrence of a specific day within the MONTHLY or YEARLY "RRULE". For example, within a MONTHLY rule, +1MO (or simply 1MO) represents the first Monday within the month, whereas -1MO represents the last Monday of the month. The numeric value in a BYDAY rule part with the FREQ rule part set to YEARLY corresponds to an offset within the month when the BYMONTH rule part is present, and corresponds to an offset within the year when the BYWEEKNO or BYMONTH rule parts are present. If an integer modifier is not present, it means all days of this type within the specified frequency. For example, within a MONTHLY rule, MO represents all Mondays within the month. The BYDAY rule part MUST NOT be specified with a numeric value when the FREQ rule part is not set to MONTHLY or YEARLY. Furthermore, the BYDAY rule part MUST NOT be specified with a numeric value with the FREQ rule part set to YEARLY when the BYWEEKNO rule part is specified. Element value is a ByDayPair that contains a DayOfWeek and an optional ordinal int. if the ordinal int is 0 then it is ignored and all values matching the DayOfWeek are included.
  • Field Details

  • Constructor Details

    • ByDay

      public ByDay()
      Parse iCalendar compliant list of days of the week. For example 1MO,2TU,4SA
    • ByDay

      public ByDay(ByDay.ByDayPair... byDayPairs)
    • ByDay

      public ByDay(ByDay source)
    • ByDay

      public ByDay(DayOfWeek... daysOfWeek)
      Constructor that uses
      invalid reference
      DayofWeek
      values without a preceding integer. All days of the provided types are included within the specified frequency
    • ByDay

      public ByDay(Collection<DayOfWeek> daysOfWeek)
      Constructor that uses
      invalid reference
      DayofWeek
      Collection. No ordinals are allowed.
  • Method Details

    • getWeekStart

      private DayOfWeek getWeekStart()
      Start of week - default start of week is Monday
    • hasOrdinals

      public boolean hasOrdinals()
      Checks if byDayPairs has ordinal values. If so returns true, otherwise false
    • addDayOfWeek

      public boolean addDayOfWeek(DayOfWeek dayOfWeek)
      add individual
      invalid reference
      DayofWeek
      , without ordinal value, to BYDAY rule
      Parameters:
      dayOfWeek -
      invalid reference
      DayofWeek
      to add, without ordinal
      Returns:
      true if added, false if DayOfWeek already present
    • removeDayOfWeek

      public boolean removeDayOfWeek(DayOfWeek dayOfWeek)
      remove individual DayofWeek from BYDAY rule
      Parameters:
      dayOfWeek -
      invalid reference
      DayofWeek
      to remove
      Returns:
      true if removed, false if not present
    • replaceDayOfWeek

      public boolean replaceDayOfWeek(DayOfWeek originalDayOfWeek, DayOfWeek replacemenDayOfWeekt)
      Replace individual
      invalid reference
      DayofWeek
      in BYDAY rule If ByDay.ByDayPair contains a non-zero ordinal, the replacement contains the same ordinal value Note: a zero ordinal means include all matching
      invalid reference
      DayofWeek
      values
      Parameters:
      original -
      invalid reference
      DayofWeek
      to remove
      replacement -
      invalid reference
      DayofWeek
      to add
      Returns:
      true if replaced, false if original is not present
    • dayOfWeekWithoutOrdinalList

      public List<DayOfWeek> dayOfWeekWithoutOrdinalList()
      Return a list of days of the week that don't have an ordinal (as every FRIDAY)
    • toString

      public String toString()
      Overrides:
      toString in class RRulePartBase<List<ByDay.ByDayPair>,ByDay>
    • streamRecurrences

      public Stream<Temporal> streamRecurrences(Stream<Temporal> inStream, ChronoUnit chronoUnit, Temporal dateTimeStart)
      Description copied from interface: ByRule
      New stream of date/times made after applying rule that either filters out some date/times or adds additional date/times.
      Specified by:
      streamRecurrences in interface ByRule<List<ByDay.ByDayPair>>
      Overrides:
      streamRecurrences in class ByRuleAbstract<ByDay.ByDayPair,ByDay>
      Parameters:
      inStream - - Current stream to be added to or subtracted from
      chronoUnit - - ChronoUnit of last modification to inStream
      Returns:
    • dayOfWeekInYear

      private TemporalAdjuster dayOfWeekInYear(int ordinal, DayOfWeek dayOfWeek)
      Finds nth occurrence of a week in a year. Based on TemporalAdjusters.dayOfWeekInMonth
    • parseContent

      protected List<VElementBase.Message> parseContent(String dayPairs)
      Description copied from class: VElementBase
      Parse content line into calendar element. If element contains children VElementBase.parseContent(String) is invoked recursively to parse child elements also
      Specified by:
      parseContent in class VElementBase
      Parameters:
      dayPairs - calendar content string to parse
      Returns:
      log of information and error messages
    • parse

      public static ByDay parse(String content)