com.comtrade.ecm.engine.datatypes

## Class Date

- java.lang.Object
- - com.comtrade.ecm.engine.datatypes.Date

-     public class Date
      extends java.lang.Object

  Object that keeps information regarding a calendar date : a year, a month [1-12], and a dayOfMonth [1-28|29|30|31].
  Month is INTENTIONALLY returned as an int, in order to avoid dependency on `Month`.
  There are no public constructors, all of the objects must be created using factory methods.
  See Also:
    Serialized Form

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `Date.Unit` Units to be used in `Date`-mathemathics.

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static java.lang.String` | `DEFAULT_DATE_FORMAT` A date-format-pattern to be used for formatting, if no other is defined.

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `Date` | `add(long amountToAdd, Date.Unit unit)` Changes a current value of an object for `amountToAdd` units of `unit`
    `int` | `compareTo(Date other)` Compares an object with another `Date`-object.
    `int` | `compareTo(DateTime other)` Compares an object with another `DateTime` object.
    `boolean` | `equals(java.lang.Object other)` Compares an object to another `Date` object.
    `int` | `getDay()`
    `int` | `getMonth()` Month is INTENTIONALLY returned as an int, in order to avoid dependency on `Month`
    `int` | `getYear()`
    `int` | `hashCode()` Hashcode of an object. Hashcode of an object will be a hashcode of its value-container object `value`
    `boolean` | `isSameDateAs(DateTime otherDateTime)` Compares an object to another `DateTime`-object. The method name is INTENTIONALLY chosen NOT TO BE `equals` in order to prevent a possible mix-up. `Date` and `DateTime` will be treated as "of same date" if they are equal on year/month/dayOfMonth level
    `static Date` | `now()` Creating a date with a current `Date` value.
    `static Date` | `of(Date date)` Creating a date from a `Date`.
    `static Date` | `of(DateTime dateTime)` Creating a date from a `DateTime`
    `static Date` | `of(java.time.LocalDate localDate)` Creates a date from a `LocalDate`
    `Date` | `toEndOfYear()`
    `java.util.Date` | `toJavaUtilDate()` Converts an object to `Date`.
    `java.time.LocalDate` | `toLocalDate()` Converts an object to `LocalDate`.
    `Date` | `toStartOfYear()`
    `java.lang.String` | `toString()` Converts to `String`, using `DEFAULT_FORMATTER`.
    `static java.lang.String` | `toString(Date date, java.time.format.DateTimeFormatter formatter)` Converts `date` to `String`, using `formatter`, following all other rules of formatting.
    `static java.lang.String` | `toString(Date date, java.util.Locale locale)` Converts `date` to `String`, using `locale`, following all other rules of formatting.
    `static java.lang.String` | `toString(Date date, java.lang.String formatDescription)` Converts `date` to `String`, using `formatDescription`, following all other rules of formatting.
    `java.lang.String` | `toString(java.time.format.DateTimeFormatter formatter)` Converts to `String`, using `formatter`.
    `java.lang.String` | `toString(java.util.Locale locale)` Converts to `String`, using `locale`.
    `java.lang.String` | `toString(java.lang.String formatDescription)` Converts to `String`, using a `DateTimeFormatter` defined by `formatDescription`.

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

      `getClass, notify, notifyAll, wait, wait, wait`

- - ### Field Detail

    - #### DEFAULT_DATE_FORMAT

          public static final java.lang.String DEFAULT_DATE_FORMAT

      A date-format-pattern to be used for formatting, if no other is defined.
      See Also:
        Constant Field Values

  - ### Method Detail

    - #### of

          public static Date of(java.time.LocalDate localDate)

      Creates a date from a `LocalDate`
      Parameters:
        `localDate` - `LocalDate` object that should be wrapped into a `Date`-object
      Returns:
        A newly created `Date`-object.

    - #### of

          public static Date of(DateTime dateTime)

      Creating a date from a `DateTime`
      Parameters:
        `dateTime` - `DateTime`-object that should be casted down to a `Date`-object.
      Returns:
        A newly created `Date`-object.

    - #### of

          public static Date of(Date date)

      Creating a date from a `Date`.
      Parameters:
        `date` - A `Date`-object that we are cloning
      Returns:
        A newly created `Date`-object.

    - #### now

          public static Date now()

      Creating a date with a current `Date` value.
      Returns:
        A newly created `Date`-object.

    - #### toStartOfYear

          public Date toStartOfYear()

      Returns:
        The first date of a year of this `Date`-object.

    - #### toEndOfYear

          public Date toEndOfYear()

      Returns:
        The last date of a year of this `Date`-object.

    - #### getYear

          public int getYear()

      Returns:
        The year of this `Date`-object

    - #### getMonth

          public int getMonth()

      Month is INTENTIONALLY returned as an int, in order to avoid dependency on `Month`
      Returns:
        the month-of-year (from 1 to 12) of this `Date`-object.

    - #### getDay

          public int getDay()

      Returns:
        the day-of-month (from 1 to 28|29|30|31) of this `Date`-object.

    - #### compareTo

          public int compareTo(Date other)

      Compares an object with another `Date`-object.
      Returns:
        -1, if `other` is not `null` and `value` is `null`,
        0, if `other` is `null` and `value` is `null`,
        1, if `other` is `null` and `value` is not `null`,
        `value.compareTo(other.value)`, otherwise.

    - #### compareTo

          public int compareTo(DateTime other)

      Compares an object with another `DateTime` object. Comparation is made only on an intersected set of attributes for `Date` and `DateTime`.
      Parameters:
        `other` - A comparing object
      Returns:
        Standard comparing return value

    - #### add

          public Date add(long amountToAdd,
                          Date.Unit unit)

      Changes a current value of an object for `amountToAdd` units of `unit`
      Parameters:
        `amountToAdd` - quantity of `unit` to be added (or subtracted, if `amountToAdd` is negative} to a current object.
        `unit` - Chrono-unit of measure
      Returns:
        A reference to a current `Date`-object

    - #### toLocalDate

          public java.time.LocalDate toLocalDate()

      Converts an object to `LocalDate`.
      Returns:
        `LocalDate` value of an object.

    - #### toJavaUtilDate

          public java.util.Date toJavaUtilDate()

      Converts an object to `Date`.
      Returns:
        `Date` value of an object.

    - #### toString

          public java.lang.String toString()

      Converts to `String`, using `DEFAULT_FORMATTER`.
      Overrides:
        `toString` in class `java.lang.Object`
      Returns:
        Date presented as a formatted string

    - #### toString

          public java.lang.String toString(java.time.format.DateTimeFormatter formatter)

      Converts to `String`, using `formatter`. If `formatter` is `null`, then a standard `toString()` is used.
      Parameters:
        `formatter` - A format to be used when formatting a date
      Returns:
        Formatted date

    - #### toString

          public java.lang.String toString(java.util.Locale locale)

      Converts to `String`, using `locale`. If `locale` is `null`, then a standard `DEFAULT_LOCALE` is used.
      Parameters:
        `locale` - A locale to be used when formatting a date
      Returns:
        Formatted date

    - #### toString

          public java.lang.String toString(java.lang.String formatDescription)

      Converts to `String`, using a `DateTimeFormatter` defined by `formatDescription`.
      Parameters:
        `formatDescription` - A String-definition of a `DateTimeFormatter` to be used when formatting a date
      Returns:
        Formatted date

    - #### toString

          public static java.lang.String toString(Date date,
                                                  java.util.Locale locale)

      Converts `date` to `String`, using `locale`, following all other rules of formatting.
      Parameters:
        `date` - A `Date`-object that should be converted to a String.
        `locale` - A locale to be used when formatting a `date`.
      Returns:
        Formatted date
      See Also:
        `toString(Locale locale)`

    - #### toString

          public static java.lang.String toString(Date date,
                                                  java.lang.String formatDescription)

      Converts `date` to `String`, using `formatDescription`, following all other rules of formatting.
      Parameters:
        `date` - A `Date`-object that should be converted to a String.
        `formatDescription` - A String-definition of a `DateTimeFormatter` to be used when formatting a `date`.
      Returns:
        Formatted date
      See Also:
        `toString(String formatDescription)`

    - #### toString

          public static java.lang.String toString(Date date,
                                                  java.time.format.DateTimeFormatter formatter)

      Converts `date` to `String`, using `formatter`, following all other rules of formatting.
      Parameters:
        `date` - A `Date`-object that should be converted to a String.
        `formatter` - A format to be used when formatting a `date`.
      Returns:
        Formatted date
      See Also:
        `toString(DateTimeFormatter formatter)`

    - #### hashCode

          public int hashCode()

      Hashcode of an object.
      Hashcode of an object will be a hashcode of its value-container object `value`
      Overrides:
        `hashCode` in class `java.lang.Object`

    - #### equals

          public boolean equals(java.lang.Object other)

      Compares an object to another `Date` object. Two `Date` objects will be treated equal, if their value-container objects `value` are equal.
      Overrides:
        `equals` in class `java.lang.Object`
      Returns:
        `true`, if objects are equal,
        `false`, otherwise.

    - #### isSameDateAs

          public boolean isSameDateAs(DateTime otherDateTime)

      Compares an object to another `DateTime`-object.
      The method name is INTENTIONALLY chosen NOT TO BE `equals` in order to prevent a possible mix-up.
      `Date` and `DateTime` will be treated as "of same date" if they are equal on year/month/dayOfMonth level
      Parameters:
        `otherDateTime` - The other object
      Returns:
        `true`, if objects are equal on an intersected set of attributes
        `false`, otherwise.