coreEngine.Helper

## Class CEDate

- java.lang.Object
- - coreEngine.Helper.CEDate

- All Implemented Interfaces:
    java.io.Serializable

      public class CEDate
      extends java.lang.Object
      implements java.io.Serializable

  This class is used to store and modify seed and RRP dates.
  Author:
    Shu Liu, Lake Trask
  See Also:
    Serialized Form

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `int` | `day` Day of the date
    `int` | `month` Month of the date
    `private static long` | `serialVersionUID` serialVersionUID
    `int` | `year` Year of the date

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `CEDate()` Default constructor
    `CEDate(int month, int day)` Constructor of CEDate class
    `CEDate(int year, int month, int day)` Constructor of CEDate class
    `CEDate(java.lang.String date)` Constructor of CEDate class

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `int` | `dayOfWeek()` Return day of week of the date
    `static int` | `dayOfWeek(CEDate date)` Return day of week of the date
    `static int` | `dayOfWeek(int day, int month, int year)` Return day of week of the date
    `static int` | `daysInMonth(int month, int year)` Return number of days in the specified month
    `static java.lang.String` | `getDayName(int dayOfWeek)` Return a String to represent day of week of a date
    `static java.lang.String` | `getMonthDayString(int month, int day)` Return a String to represent the month and day of week of a date
    `static int` | `getMonthNumber(java.lang.String monthName)` Getter for month index (start with 1)
    `static java.lang.String` | `getMonthString(int month)` Return a String to represent the month
    `boolean` | `isAfter(CEDate date)` Method that checks if this CEDate is after another.
    `boolean` | `isAfterOrSameAs(CEDate date)` Compare two dates
    `boolean` | `isBefore(CEDate date)` Method that checks if this CEDate is before another.
    `boolean` | `isBeforeOrSameAs(CEDate date)` Compare two dates
    `boolean` | `isSameDateAs(CEDate date)` Method to check if two dates are the same.
    `static int[]` | `numDayOfWeekInMonthAP(DemandData demandData)` Return number of days of week per month in the total year.
    `static int[]` | `numDayOfWeekInMonthAP(int analysisYear, boolean[] activeDays)` Return number of days of week in a period
    `static int[]` | `numDayOfWeekInMonthAP(int analysisYear, int startMonth, int startDay, int endMonth, int endDay, boolean[] activeDays)` Return number of days of week in a period
    `static int[]` | `numEachDayOfWeekInPeriod(int year, int month, int startDay, int endDay)` Returns a integer array of length 7.
    `java.lang.String` | `toString()`
    `java.lang.String` | `toWorkZoneString()` Return a String to represent the work zone

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

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

- - ### Field Detail

    - #### serialVersionUID

          private static final long serialVersionUID

      serialVersionUID
      See Also:
        Constant Field Values

    - #### year

          public int year

      Year of the date

    - #### month

          public int month

      Month of the date

    - #### day

          public int day

      Day of the date

  - ### Constructor Detail

    - #### CEDate

          public CEDate()

      Default constructor

    - #### CEDate

          public CEDate(int month,
                        int day)

      Constructor of CEDate class
      Parameters:
        `month` - month of the date
        `day` - day of the date

    - #### CEDate

          public CEDate(int year,
                        int month,
                        int day)

      Constructor of CEDate class
      Parameters:
        `year` - year of the date
        `month` - month of the date
        `day` - day of the date

    - #### CEDate

          public CEDate(java.lang.String date)

      Constructor of CEDate class
      Parameters:
        `date` - date in String (YYYY-MM-DD)

  - ### Method Detail

    - #### dayOfWeek

          public int dayOfWeek()

      Return day of week of the date
      Returns:
        index of the day of the week 0 - Monday, 1 -Tuesday, 2 - Wednesday 3 - Thursday, 4 - Friday, 5 - Saturday, 6 - Sunday.

    - #### dayOfWeek

          public static int dayOfWeek(CEDate date)

      Return day of week of the date
      Parameters:
        `date` - CEDate instance
      Returns:
        index of the day of the week 0 - Monday, 1 -Tuesday, 2 - Wednesday 3 - Thursday, 4 - Friday, 5 - Saturday, 6 - Sunday.

    - #### dayOfWeek

          public static int dayOfWeek(int day,
                                      int month,
                                      int year)

      Return day of week of the date
      Parameters:
        `day` - day of the date (1,...,31)
        `month` - month of the date (1,...,12)
        `year` - year of the date (...,2010,2011,...)
      Returns:
        index of the day of the week 0 - Monday, 1 -Tuesday, 2 - Wednesday 3 - Thursday, 4 - Friday, 5 - Saturday, 6 - Sunday.

    - #### daysInMonth

          public static int daysInMonth(int month,
                                        int year)

      Return number of days in the specified month
      Parameters:
        `month` - month of the date
        `year` - year of the date
      Returns:
        Number of days in the specified month

    - #### numDayOfWeekInMonthAP

          public static int[] numDayOfWeekInMonthAP(int analysisYear,
                                                    boolean[] activeDays)

      Return number of days of week in a period
      Parameters:
        `analysisYear` - year of the analysis date
        `activeDays` - active days in the period
      Returns:
        number of days of week in a period

    - #### numDayOfWeekInMonthAP

          public static int[] numDayOfWeekInMonthAP(int analysisYear,
                                                    int startMonth,
                                                    int startDay,
                                                    int endMonth,
                                                    int endDay,
                                                    boolean[] activeDays)

      Return number of days of week in a period
      Parameters:
        `analysisYear` - year of the analysis period
        `startMonth` - month of the start date
        `startDay` - day of the start date
        `endMonth` - month of the end date
        `endDay` - month of the end date
        `activeDays` - active days in the period
      Returns:
        number of days of week in a period

    - #### numDayOfWeekInMonthAP

          public static int[] numDayOfWeekInMonthAP(DemandData demandData)

      Return number of days of week per month in the total year.
      Parameters:
        `demandData` - demand data
      Returns:
        number of days of week per month in the total year (84 length array)

    - #### numEachDayOfWeekInPeriod

          public static int[] numEachDayOfWeekInPeriod(int year,
                                                       int month,
                                                       int startDay,
                                                       int endDay)

      Returns a integer array of length 7. Each value is the number of that day type in the given portion of a month. For example, numDayInMonth[0] = 4 indicates that there are 4 Mondays in the specified portion of the month. Note: whether or not a day is active in the study period is not considered.
      Parameters:
        `year` - year
        `month` - month
        `startDay` - start day
        `endDay` - end day
      Returns:
        a integer array of length 7

    - #### isBefore

          public boolean isBefore(CEDate date)

      Method that checks if this CEDate is before another. Return true if before, returns false if they are the same date or this date is after the input date.
      Parameters:
        `date` - date to compare
      Returns:
        whether this CEDate is before another

    - #### isAfter

          public boolean isAfter(CEDate date)

      Method that checks if this CEDate is after another. Return true if after, returns false if they are the same date or this date is before the input date.
      Parameters:
        `date` - date to compare
      Returns:
        whether this CEDate is after another

    - #### isSameDateAs

          public boolean isSameDateAs(CEDate date)

      Method to check if two dates are the same.
      Parameters:
        `date` - date to compare
      Returns:
        whether two dates are the same

    - #### isBeforeOrSameAs

          public boolean isBeforeOrSameAs(CEDate date)

      Compare two dates
      Parameters:
        `date` - date to compare
      Returns:
        whether this date is before or same as the other

    - #### isAfterOrSameAs

          public boolean isAfterOrSameAs(CEDate date)

      Compare two dates
      Parameters:
        `date` - date to compare
      Returns:
        whether this date is after or same as the other

    - #### getMonthDayString

          public static java.lang.String getMonthDayString(int month,
                                                           int day)

      Return a String to represent the month and day of week of a date
      Parameters:
        `month` - month of the date
        `day` - day of the date
      Returns:
        a String to represent the month and day of week of a date

    - #### getMonthString

          public static java.lang.String getMonthString(int month)

      Return a String to represent the month
      Parameters:
        `month` - month
      Returns:
        String of full name of month

    - #### getMonthNumber

          public static int getMonthNumber(java.lang.String monthName)

      Getter for month index (start with 1)
      Parameters:
        `monthName` - month name
      Returns:
        month index (start with 1)

    - #### getDayName

          public static java.lang.String getDayName(int dayOfWeek)

      Return a String to represent day of week of a date
      Parameters:
        `dayOfWeek` - day of week of the date
      Returns:
        a String to represent day of week of a date

    - #### toString

          public java.lang.String toString()

      Overrides:
        `toString` in class `java.lang.Object`

    - #### toWorkZoneString

          public java.lang.String toWorkZoneString()

      Return a String to represent the work zone
      Returns:
        a String to represent the work zone