Class SpanOfWeekdays

All Implemented Interfaces:
Serializable, Iterable<Weekday>, ChronoDisplay

@CalendarType("iso8601") public final class SpanOfWeekdays extends ChronoEntity<SpanOfWeekdays> implements Iterable<Weekday>, Serializable

Describes an arbitrary span of weekdays.

Following elements which are declared as constants are registered by this class:

Since:
4.20
Author:
Meno Hochschild
See Also:
Serialized Form
  • Field Details

  • Method Details

    • on

      public static SpanOfWeekdays on(Weekday day)

      Creates a span of weekdays of only one day.

      Parameters:
      day - the single day of week which forms the span
      Returns:
      span of weekdays consisting of only given day
    • betweenMondayAndFriday

      public static SpanOfWeekdays betweenMondayAndFriday()

      Creates a typical working week from Monday to Friday.

      Returns:
      span of weekdays from Monday to Friday
    • between

      public static SpanOfWeekdays between(Weekday start, Weekday end)

      Creates a new span of weekdays.

      It is possible to choose the same weekday for start and end. Then the resulting span will just consist of one single weekday.

      Parameters:
      start - the starting weekday
      end - the ending weekday (inclusive)
      Returns:
      new span of weekdays
    • getStart

      public Weekday getStart()

      Obtains the start of this span of weekdays.

      Returns:
      the starting weekday
    • getEnd

      public Weekday getEnd()

      Obtains the end of this span of weekdays.

      Returns:
      the ending weekday
    • length

      public int length()

      Determines the count of days belonging to this span of weekdays.

      Returns:
      count of days in range 1-7
    • iterator

      public Iterator<Weekday> iterator()
      Specified by:
      iterator in interface Iterable<Weekday>
    • formatter

      public static ChronoFormatter<SpanOfWeekdays> formatter(String dynamicPattern, Locale locale)

      Creates a formatter for given dynamic format pattern and locale.

      The pattern is of dynamic type and only uses the symbol letters "S" (=START) and "E" (=END). The start must be present, but the end is optional. If the end is missing in parsing then it will be set to the start. The count of symbols controls the text width, and the output context can be set by an extra format attribute. Example:

           ChronoFormatter<SpanOfWeekdays> f =
                SpanOfWeekdays.formatter("SSSS[ 'to' EEEE]", Locale.ENGLISH);
      
           assertThat(f.format(SpanOfWeekdays.betweenMondayAndFriday()), is("Monday to Friday"));
           assertThat(f.parse("Sunday"), is(SpanOfWeekdays.on(Weekday.SUNDAY)));
       
      Parameters:
      dynamicPattern - format pattern
      locale - the locale information
      Returns:
      new formatter
      See Also:
      START, END, PatternType.DYNAMIC, Attributes.OUTPUT_CONTEXT
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • chronology

      public static Chronology<SpanOfWeekdays> chronology()

      Yields the associated chronology.

      Returns:
      the underlying rule engine