org.apache.poi.ss.formula.atp

## Class WorkdayCalculator

- java.lang.Object
- - org.apache.poi.ss.formula.atp.WorkdayCalculator

-     public class WorkdayCalculator
      extends java.lang.Object

  A calculator for workdays, considering dates as excel representations.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static WorkdayCalculator` | `instance`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected int` | `calculateNonWeekendHolidays(double start, double end, double[] holidays)` Calculates how many holidays in a list are workdays, considering an interval of dates.
    `int` | `calculateWorkdays(double start, double end, double[] holidays)` Calculate how many workdays are there between a start and an end date, as excel representations, considering a range of holidays.
    `java.util.Date` | `calculateWorkdays(double start, int workdays, double[] holidays)` Calculate the workday past x workdays from a starting date, considering a range of holidays.
    `protected boolean` | `isHoliday(double aDate, double[] holidays)`
    `protected boolean` | `isInARange(double start, double end, double aDate)`
    `protected boolean` | `isWeekend(double aDate)`
    `protected int` | `pastDaysOfWeek(double start, double end, int dayOfWeek)` Calculates how many days of week past between a start and an end date.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### instance

          public static final WorkdayCalculator instance

  - ### Method Detail

    - #### calculateWorkdays

          public int calculateWorkdays(double start,
                                       double end,
                                       double[] holidays)

      Calculate how many workdays are there between a start and an end date, as excel representations, considering a range of holidays.
      Parameters:
        `start` - start date.
        `end` - end date.
        `holidays` - an array of holidays.
      Returns:
        number of workdays between start and end dates, including both dates.

    - #### calculateWorkdays

          public java.util.Date calculateWorkdays(double start,
                                                  int workdays,
                                                  double[] holidays)

      Calculate the workday past x workdays from a starting date, considering a range of holidays.
      Parameters:
        `start` - start date.
        `workdays` - number of workdays to be past from starting date.
        `holidays` - an array of holidays.
      Returns:
        date past x workdays.

    - #### pastDaysOfWeek

          protected int pastDaysOfWeek(double start,
                                       double end,
                                       int dayOfWeek)

      Calculates how many days of week past between a start and an end date.
      Parameters:
        `start` - start date.
        `end` - end date.
        `dayOfWeek` - a day of week as represented by `Calendar` constants.
      Returns:
        how many days of week past in this interval.

    - #### calculateNonWeekendHolidays

          protected int calculateNonWeekendHolidays(double start,
                                                    double end,
                                                    double[] holidays)

      Calculates how many holidays in a list are workdays, considering an interval of dates.
      Parameters:
        `start` - start date.
        `end` - end date.
        `holidays` - an array of holidays.
      Returns:
        number of holidays that occur in workdays, between start and end dates.

    - #### isWeekend

          protected boolean isWeekend(double aDate)

      Parameters:
        `aDate` - a given date.
      Returns:
        `true` if date is weekend, `false` otherwise.

    - #### isHoliday

          protected boolean isHoliday(double aDate,
                                      double[] holidays)

      Parameters:
        `aDate` - a given date.
        `holidays` - an array of holidays.
      Returns:
        `true` if date is a holiday, `false` otherwise.

    - #### isInARange

          protected boolean isInARange(double start,
                                       double end,
                                       double aDate)

      Parameters:
        `start` - start date.
        `end` - end date.
        `aDate` - a date to be analyzed.
      Returns:
        `true` if aDate is between start and end dates, `false` otherwise.

Copyright 2020 The Apache Software Foundation or its licensors, as applicable.