Class HistoricDate

java.lang.Object
net.time4j.history.HistoricDate
All Implemented Interfaces:
Comparable<HistoricDate>

public final class HistoricDate extends Object implements Comparable<HistoricDate>

Defines a historic date which consists of era, year of era, month and day of month.

Instances of this class are agnostic of any specific new-year-strategy other than the default (first of January) but can use such a strategy as parameter to determine the real historic year for display purposes.

The natural order is based on the timeline order.

Since:
3.0
Author:
Meno Hochschild
  • Method Details

    • of

      public static HistoricDate of(HistoricEra era, int yearOfEra, int month, int dom)

      Equivalent to HistoricDate.of(era, yearOfEra, month, dom, YearDefinition.DUAL_DATING, NewYearRule.BEGIN_OF_JANUARY.until(Integer.MAX_VALUE)).

      Parameters:
      era - historic era
      yearOfEra - year of related era (1 <= yearOfEra) starting on January the first
      month - historic month (1-12)
      dom - historic day of month (1-31)
      Returns:
      new historic date (not yet validated)
      Throws:
      IllegalArgumentException - if any argument is out of required maximum range
      Since:
      3.0
      See Also:
      ChronoHistory.isValid(HistoricDate)
    • of

      public static HistoricDate of(HistoricEra era, int yearOfEra, int month, int dom, YearDefinition yearDefinition, NewYearStrategy newYearStrategy)

      Constructs a new tuple of given historic chronological components.

      Note: A detailed validation is not done. Such a validation is the responsibility of any ChronoHistory, however.

      Parameters:
      era - historic era
      yearOfEra - positive year of era which will be interpreted according to given year definition
      month - historic month (1-12)
      dom - historic day of month (1-31)
      yearDefinition - defines a strategy how to interprete year of era
      newYearStrategy - strategy how to determine New Year
      Returns:
      new historic date (not yet validated)
      Throws:
      IllegalArgumentException - if any argument is out of required maximum range or inconsistent
      Since:
      3.18/4.14
      See Also:
      ChronoHistory.isValid(HistoricDate)
    • getEra

      public HistoricEra getEra()

      Yields the historic era.

      Returns:
      HistoricEra
      Since:
      3.0
    • getYearOfEra

      public int getYearOfEra()

      Yields the year of the historic era starting on January the first.

      Returns:
      year of era
      Since:
      3.0
      See Also:
      getYearOfEra(NewYearStrategy), NewYearRule.BEGIN_OF_JANUARY
    • getYearOfEra

      public int getYearOfEra(NewYearStrategy newYearStrategy)

      Yields the displayed historic year whose begin is determined by given new-year-strategy.

      Parameters:
      newYearStrategy - strategy how to determine New Year
      Returns:
      displayed historic year (never negative)
      Since:
      3.14/4.11
      See Also:
      getYearOfEra(), NewYearRule
    • getMonth

      public int getMonth()

      Yields the historic month.

      Returns:
      month (1-12)
      Since:
      3.0
    • getDayOfMonth

      public int getDayOfMonth()

      Yields the historic day of month.

      Returns:
      day of month (1-31)
      Since:
      3.0
    • compareTo

      public int compareTo(HistoricDate other)
      Specified by:
      compareTo in interface Comparable<HistoricDate>
    • 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