Class EastAsianCalendar<U,​D extends EastAsianCalendar<U,​D>>

java.lang.Object
net.time4j.engine.ChronoEntity<T>
net.time4j.engine.TimePoint<U,​D>
net.time4j.engine.Calendrical<U,​D>
net.time4j.calendar.EastAsianCalendar<U,​D>
All Implemented Interfaces:
Serializable, Comparable<D>, CalendarDate, ChronoDisplay, Temporal<CalendarDate>
Direct Known Subclasses:
ChineseCalendar, KoreanCalendar, VietnameseCalendar

public abstract class EastAsianCalendar<U,​D extends EastAsianCalendar<U,​D>> extends Calendrical<U,​D>

Base class of all calendars which are derivates of the lunisolar rural calendar invented in China.

The underlying calendrical algorithms are based on the astronomical formula of Jean Meeus and the book "Calendrical Calculations" by Dershowitz/Reingold. The differences between the concrete subclasses are mainly limited to the supported date range and the geographical meridian defining the timezone offset for evaluating the astronomical data.

Since:
3.40/4.35
Author:
Meno Hochschild
See Also:
Serialized Form
  • Method Details

    • getYear

      public CyclicYear getYear()

      Obtains the cyclic year (using a sexagesimal cycle).

      Returns:
      CyclicYear
    • getSolarTerm

      public SolarTerm getSolarTerm()

      Obtains the solar term as one of 24 on the ecliptic of the sun.

      Returns:
      SolarTerm
    • getMonth

      public EastAsianMonth getMonth()

      Yields the (lunar) month including the numerical value and the possible leap month flag.

      Returns:
      EastAsianMonth
    • getDayOfMonth

      public int getDayOfMonth()

      Yields the day of month in the range 1-29/30.

      Returns:
      int
    • getDayOfWeek

      public Weekday getDayOfWeek()

      Determines the day of week.

      Returns:
      Weekday
    • getDayOfYear

      public int getDayOfYear()

      Yields the day of year.

      Returns:
      int >= 1
    • getSexagesimalMonth

      public SexagesimalName getSexagesimalMonth()

      Obtains the sexagesimal name of solar month component which repeats every 60th solar term.

      Returns:
      SexagesimalName
      Since:
      5.7
      See Also:
      getSolarTerm()
    • getSexagesimalDay

      public SexagesimalName getSexagesimalDay()

      Obtains the sexagesimal name of day component which repeats every 60th day.

      Returns:
      SexagesimalName
      Since:
      5.7
    • isLeapYear

      public boolean isLeapYear()

      Is the year of this date a leap year such that it contains a leap month?

      Returns:
      boolean
      See Also:
      findLeapMonth(), withBeginOfNextLeapMonth()
    • findLeapMonth

      public Optional<EastAsianMonth> findLeapMonth()

      Tries to obtain the leap month of the calendar year associated with this calendar date.

      Note: If the current year is a leap year then it is possible that the found leap month is before the current calendar date.

      Returns:
      optional East Asian month as leap month of current calendar year
      Since:
      5.8
      See Also:
      isLeapYear(), withBeginOfNextLeapMonth()
    • withBeginOfNextLeapMonth

      public D withBeginOfNextLeapMonth()

      Obtains the calendar date of the begin of next leap month.

      Example:

           ChineseCalendar cc = ChineseCalendar.ofNewYear(2018);
           cc = cc.withBeginOfNextLeapMonth();
           System.out.println(cc); // chinese[geng-zi(2020)-*4-01]
       
      Returns:
      the calendar date when the next leap month starts
      Throws:
      IllegalArgumentException - if the next leap month is out of range of supported calendar dates
      Since:
      5.8
      See Also:
      isLeapYear(), findLeapMonth()
    • lengthOfMonth

      public int lengthOfMonth()

      Yields the length of current month in days.

      Returns:
      int
    • lengthOfYear

      public int lengthOfYear()

      Yields the length of current year in days.

      Returns:
      int
    • at

      public GeneralTimestamp<D> at(PlainTime time)

      Creates a new local timestamp with this date and given wall time.

      If the time T24:00 is used then the resulting timestamp will automatically be normalized such that the timestamp will contain the following day instead.

      Parameters:
      time - wall time
      Returns:
      general timestamp as composition of this date and given time
    • atTime

      public GeneralTimestamp<D> atTime(int hour, int minute)

      Is equivalent to at(PlainTime.of(hour, minute)).

      Parameters:
      hour - hour of day in range (0-24)
      minute - minute of hour in range (0-59)
      Returns:
      general timestamp as composition of this date and given time
      Throws:
      IllegalArgumentException - if any argument is out of range
      See Also:
      at(PlainTime)
    • getDaysSinceEpochUTC

      public long getDaysSinceEpochUTC()
      Description copied from interface: CalendarDate

      Counts the elapsed days since UTC epoch.

      Specified by:
      getDaysSinceEpochUTC in interface CalendarDate
      Overrides:
      getDaysSinceEpochUTC in class Calendrical<U,​D extends EastAsianCalendar<U,​D>>
      Returns:
      count of days relative to UTC epoch [1972-01-01]
      See Also:
      EpochDays.UTC
    • equals

      public boolean equals(Object obj)
      Description copied from class: Calendrical

      Based on the epoch day number and the calendar system.

      In other words: Two date object are equal if they have the same temporal position on the local timeline and have the same calendrical type. Subclasses which define further state attributes must override this method.

      If an only temporal comparison is required then the method Calendrical.isSimultaneous(CalendarDate) is to be used.

      Overrides:
      equals in class Calendrical<U,​D extends EastAsianCalendar<U,​D>>
      See Also:
      Chronology.getChronoType()
    • hashCode

      public int hashCode()
      Description copied from class: Calendrical

      Based on the epoch day number.

      Overrides:
      hashCode in class Calendrical<U,​D extends EastAsianCalendar<U,​D>>
    • toString

      public String toString()
      Description copied from class: TimePoint

      Provides a complete textual representation of the state of this time point.

      The textual description often follows the conventions of ISO-8601. Usually the description starts with the chronological informations which are coarse-grained and ends with those ones which are fine-grained (for example the ISO-notation YYYY-MM-DD).

      Specified by:
      toString in class TimePoint<U,​D extends EastAsianCalendar<U,​D>>