Class ChineseCalendar
java.lang.Object
org.episteme.social.history.calendars.AlternateCalendar
org.episteme.social.history.calendars.SevenDaysWeek
org.episteme.social.history.calendars.MonthDayYear
org.episteme.social.history.calendars.ChineseCalendar
- All Implemented Interfaces:
Serializable
Implementation of the traditional Chinese lunisolar calendar.
The Chinese calendar is one of the oldest chronological systems still in use,
incorporating both astronomical observations and traditional cultural cycles.
Key features:
- Epoch: February 15, 2636 BCE
- Uses a 60-year cycle (Sexagenary cycle) combining Heavenly Stems and Earthly Branches
- Months are lunar, beginning with the new moon
- Uses astronomical calculations for new moons and solar terms
- Leap months are intercalated to align with the solar year
- Year names combine celestial stem and terrestrial branch (e.g., "Jia-Zi")
- Since:
- 1.0
- Author:
- Silvere Martin-Michiellot, Gemini AI (Google DeepMind)
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final longThe RD number for the Chinese calendar epoch (February 15, 2636 BCE).static final intThe year of the epoch relative to CE.static final String[]List of Chinese solar terms corresponding to months.Fields inherited from class MonthDayYear
day, month, yearFields inherited from class SevenDaysWeek
DAY_NAMES, FRIDAY, MONDAY, SATURDAY, SUNDAY, THURSDAY, TUESDAY, WEDNESDAYFields inherited from class AlternateCalendar
JD_EPOCH, rd, unicode -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new ChineseCalendar object.ChineseCalendar(int i, int j, int k, boolean flag, int l) Creates a new ChineseCalendar object.ChineseCalendar(long l) Creates a new ChineseCalendar object. -
Method Summary
Modifier and TypeMethodDescriptionstatic longdateNextSolarLongitude(double d, int i) Finds the date of the next time the sun reacher a specific longitude.booleangetLeap()Returns the leap month status of the current date.Returns an enumeration of all Chinese month names.Returns the suffix for Chinese years (empty).static voidMain method for testing the Chinese calendar implementation.static intmajorSolarTerm(long l) Returns the major solar term (Zhongqi) for the given date.static longmajorSolarTermOnOrAfter(double d) Returns the RD of the next major solar term (Zhongqi) on or after the date.Returns the name of the current lunar month, including leap status.static longnewMoonBefore(long l) Returns the RD of the last new moon before the given RD.static longnewMoonOnOrAfter(long l) Returns the RD of the next new moon on or after the given RD.static longnewYear(int i) Finds the Rata Die of the Chinese New Year for a given Gregorian year.static booleannoMajorSolarTerm(long l) Determines if a month (defined by its starting RD) contains no major solar term.static booleanpriorLeapMonth(long l, long l1) Determines if there is a leap month between two dates.voidRecomputes the cycle, year, month, day, and leap status from the current Rata Die.voidRecomputes the Rata Die number from current Chinese date components.voidset(int i, int j, int k) Sets the month, day, and year (combined from cycle and year-in-cycle).voidset(int i, int j, int k, boolean flag, int l) Sets the cycle, year-in-cycle, month, leap status, and day.voidset(long l) Sets the Rata Die number and recomputes the date fields.doubletimeZone()Returns the time zone offset for the current RD.static doubletimeZone(long l) Returns the time zone offset in minutes for the given RD.toString()Returns a string representation of the Chinese date.Methods inherited from class MonthDayYear
getDay, getMonth, getYearMethods inherited from class SevenDaysWeek
kDayAfter, kDayBefore, kDayNearest, kDayOnOrAfter, kDayOnOrBefore, nthKDay, weekDay, weekDayNameMethods inherited from class AlternateCalendar
add, amod, difference, difference, floorDiv, fromJD, isAfter, isBefore, mod, mod, subtract, toJD, toJD, toRD
-
Field Details
-
MONTHS
List of Chinese solar terms corresponding to months. -
EPOCH
public static final long EPOCHThe RD number for the Chinese calendar epoch (February 15, 2636 BCE). -
EPOCHYEAR
public static final int EPOCHYEARThe year of the epoch relative to CE.- See Also:
-
-
Constructor Details
-
ChineseCalendar
public ChineseCalendar(long l) Creates a new ChineseCalendar object.- Parameters:
l- the Rata Die number.
-
ChineseCalendar
public ChineseCalendar(int i, int j, int k, boolean flag, int l) Creates a new ChineseCalendar object.- Parameters:
i- the cycle number.j- the year in cycle (1-60).k- the month (1-12).flag- true if leap month.l- the day (1-30).
-
ChineseCalendar
public ChineseCalendar()Creates a new ChineseCalendar object.
-
-
Method Details
-
majorSolarTerm
public static int majorSolarTerm(long l) Returns the major solar term (Zhongqi) for the given date.- Parameters:
l- the Rata Die number.- Returns:
- the major solar term (1-12).
-
timeZone
public static double timeZone(long l) Returns the time zone offset in minutes for the given RD. Beijing time (UTC+8) is used since 1929.- Parameters:
l- the Rata Die number.- Returns:
- the time zone offset in minutes.
-
timeZone
public double timeZone()Returns the time zone offset for the current RD.- Returns:
- the time zone offset.
-
dateNextSolarLongitude
public static long dateNextSolarLongitude(double d, int i) Finds the date of the next time the sun reacher a specific longitude.- Parameters:
d- the starting RD.i- the longitude increment (typically 30).- Returns:
- the RD of the event.
-
majorSolarTermOnOrAfter
public static long majorSolarTermOnOrAfter(double d) Returns the RD of the next major solar term (Zhongqi) on or after the date.- Parameters:
d- the starting RD.- Returns:
- the RD of the next major solar term.
-
newMoonOnOrAfter
public static long newMoonOnOrAfter(long l) Returns the RD of the next new moon on or after the given RD.- Parameters:
l- the starting RD.- Returns:
- the RD of the next new moon.
-
newMoonBefore
public static long newMoonBefore(long l) Returns the RD of the last new moon before the given RD.- Parameters:
l- the starting RD.- Returns:
- the RD of the previous new moon.
-
noMajorSolarTerm
public static boolean noMajorSolarTerm(long l) Determines if a month (defined by its starting RD) contains no major solar term.- Parameters:
l- the starting RD of the lunar month.- Returns:
- true if the month has no major solar term.
-
priorLeapMonth
public static boolean priorLeapMonth(long l, long l1) Determines if there is a leap month between two dates.- Parameters:
l- the starting RD.l1- the ending RD.- Returns:
- true if a leap month exists in the range.
-
recomputeFromRD
public void recomputeFromRD()Recomputes the cycle, year, month, day, and leap status from the current Rata Die.- Specified by:
recomputeFromRDin classAlternateCalendar
-
newYear
public static long newYear(int i) Finds the Rata Die of the Chinese New Year for a given Gregorian year.- Parameters:
i- the Gregorian year.- Returns:
- the RD of the Chinese New Year.
-
recomputeRD
public void recomputeRD()Recomputes the Rata Die number from current Chinese date components.- Specified by:
recomputeRDin classAlternateCalendar
-
set
public void set(long l) Sets the Rata Die number and recomputes the date fields.- Specified by:
setin classAlternateCalendar- Parameters:
l- the Rata Die number.
-
set
public void set(int i, int j, int k) Sets the month, day, and year (combined from cycle and year-in-cycle).- Overrides:
setin classMonthDayYear- Parameters:
i- the month.j- the day.k- the year.
-
set
public void set(int i, int j, int k, boolean flag, int l) Sets the cycle, year-in-cycle, month, leap status, and day.- Parameters:
i- the cycle.j- the year in cycle (1-60).k- the month.flag- true if leap month.l- the day.
-
getLeap
public boolean getLeap()Returns the leap month status of the current date.- Returns:
- true if it is a leap month.
-
getSuffix
Returns the suffix for Chinese years (empty).- Specified by:
getSuffixin classMonthDayYear- Returns:
- an empty string.
-
monthName
Returns the name of the current lunar month, including leap status.- Specified by:
monthNamein classMonthDayYear- Returns:
- the month name string.
-
getMonths
Returns an enumeration of all Chinese month names.- Specified by:
getMonthsin classMonthDayYear- Returns:
- enumeration of month names.
-
toString
Returns a string representation of the Chinese date.- Overrides:
toStringin classMonthDayYear- Returns:
- the date string.
-
main
Main method for testing the Chinese calendar implementation.- Parameters:
args- command line arguments.
-