Record Class EarlyCloseHoliday

java.lang.Object
java.lang.Record
org.holiday.calendar.EarlyCloseHoliday
All Implemented Interfaces:
Holiday

public record EarlyCloseHoliday(String name, String description, Observance observance, LocalTime closeTime, ZoneId zoneId) extends Record implements Holiday
A holiday which represents a partial trading day — a day on which a market or exchange closes early rather than closing for the entire day. Examples are the holiday eves observed by the Tel Aviv Stock Exchange (e.g. Erev Rosh Hashanah, Erev Yom Kippur), on which trading halts around midday.

Like a FloatingHoliday, the calendar date of an early close is computed per year via an Observance. In addition, an early close carries the local time at which trading ceases and the time zone in which that time is expressed.

An early close is inherently non-rollable: it is tied to the specific calendar day preceding the associated full holiday and is never adjusted for weekend observance — e.g. a Christmas Eve early close always occurs on Dec 24, never rolled to Dec 23 or Dec 26. Consequently, early closes are excluded from HolidayCalendar.calculate(int) and are reported separately by HolidayCalendar.calculateEarlyCloses(int).

Instances are immutable, thread-safe records constructed via Holiday.builder() with Holiday.Type.EARLY_CLOSE:


 Holiday christmasEveEarlyClose = Holiday.builder()
     .name("Christmas Eve")
     .description("NYSE 1:00pm ET early close")
     .type(Holiday.Type.EARLY_CLOSE)
     .rollable(false)
     .observance(new ChristmasEveEarlyClose())
     .closeTime(LocalTime.of(13, 0))
     .zoneId(ZoneId.of("America/New_York"))
     .build();
 
Author:
Dave Joyce
See Also:
  • Constructor Details

  • Method Details

    • getName

      public String getName()
      Description copied from interface: Holiday
      Get the name of this holiday.
      Specified by:
      getName in interface Holiday
      Returns:
      holiday name
    • getDescription

      public String getDescription()
      Description copied from interface: Holiday
      Get the description (if any) of this holiday.
      Specified by:
      getDescription in interface Holiday
      Returns:
      holiday description
    • isRollable

      public boolean isRollable()
      Determine if this holiday supports date rolling for actual observance on a holiday calendar.

      An early close is always non-rollable; this method always returns false.

      Specified by:
      isRollable in interface Holiday
      Returns:
      true if the date of occurrence for this holiday may be rolled for observance, false otherwise
    • getObservance

      public Observance getObservance()
    • getCloseTime

      public LocalTime getCloseTime()
      Get the local time at which trading ceases on this early-close day.
      Returns:
      early close time, expressed in the zone of this holiday
    • getZoneId

      public ZoneId getZoneId()
      Get the time zone in which this holiday's close time is expressed.
      Returns:
      early close time zone
    • dateForYear

      public Optional<LocalDate> dateForYear(int year)
      Description copied from interface: Holiday
      Calculate the date of this holiday for the specified year. The date returned by this method may be adjusted to a different date of observance by the associated holiday calendar.
      Specified by:
      dateForYear in interface Holiday
      Parameters:
      year - full calendar year (e.g. 1977, 2021)
      Returns:
      date of this holiday, or empty if not observed on the specified year
    • toString

      public String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • name

      public String name()
      Returns the value of the name record component.
      Returns:
      the value of the name record component
    • description

      public String description()
      Returns the value of the description record component.
      Returns:
      the value of the description record component
    • observance

      public Observance observance()
      Returns the value of the observance record component.
      Returns:
      the value of the observance record component
    • closeTime

      public LocalTime closeTime()
      Returns the value of the closeTime record component.
      Returns:
      the value of the closeTime record component
    • zoneId

      public ZoneId zoneId()
      Returns the value of the zoneId record component.
      Returns:
      the value of the zoneId record component