Lunar is a dependency free calendar tool library that supports the solar and lunar calendar. It is available in js, java, c#, php, python, go, typescript, flutter, and is independent of third parties. Currently supports the Gregorian calendar and lunar calendar, constellations, dry branches, Chinese zodiac, solar terms, festivals, Pengzu hundred taboo, daily taboo, auspicious gods, auspicious gods, evil spirits, auspicious gods, Chong Sha, Na Yin, stars, eight characters, five elements, ten gods, building in addition to twelve stars, twelve gods such as Green Dragon Hall, Zodiacal day and auspicious and ominous.
Quick Start (Java version) :
Depend on
// maven<dependency><groupId>cn.6tail</groupId><artifactId>lunar</artifactId><version>1.2.5</version></dependency>
// gradleimplementation 'com.github.6tail:lunar-java:v1.2.5'
- Sample code
Solar calenda
// Year Month daySolar d = Solar.fromYmd(2016, 1, 1);System.out.println(d);// Year, month, day, minute and secondd = Solar.fromYmdHms(2016, 1, 1, 20, 35, 0);System.out.println(d);// 日期d = Solar.fromDate(new Date());System.out.println(d.toFullString());// 儒略日d = Solar.fromJulianDay(2458960.5);System.out.println(d.toFullString());// 八字反推阳历List<Solar> l = Solar.fromBaZi("庚子", "辛巳", "庚午", "丙子");for (Solar solar : l) {System.out.println(solar.toFullString());}
output
horoscope
//horoscopeLunar lunar = Lunar.fromDate(new Date());EightChar d = lunar.getEightChar();System.out.println(d);System.out.println(d.getYearWuXing() + ", " + d.getMonthWuXing() + ", " + d.getDayWuXing() + ", " + d.getTimeWuXing());System.out.println(d.getYearNaYin() + ", " + d.getMonthNaYin() + ", " + d.getDayNaYin() + ", " + d.getTimeNaYin());System.out.println(d.getYearShiShenGan() + ", " + d.getMonthShiShenGan() + ", " + d.getDayShiShenGan() + ", " + d.getTimeShiShenGan());// 年支十神System.out.println("年支十神 = " + d.getYearShiShenZhi());// 月支十神System.out.println("月支十神 = " + d.getMonthShiShenZhi());// 日支十神System.out.println("日支十神 = " + d.getDayShiShenZhi());// 时支十神System.out.println("时支十神 = " + d.getTimeShiShenZhi());// 获取男运Yun yun = d.getYun(1);// 起运System.out.println("出生" + yun.getStartYear() + "年" + yun.getStartMonth() + "个月" + yun.getStartDay() + "天后起运");// 获取大运表DaYun[] daYunArr = yun.getDaYun();for (int i=0, j=daYunArr.length; i<j; i++) {DaYun daYun = daYunArr[i];System.out.println("大运[" + i + "] = " + daYun.getStartYear() + "年 " + daYun.getStartAge() + "岁 " + daYun.getGanZhi());}// 第1次大运流年LiuNian[] LiuNianArr = daYunArr[1].getLiuNian();for (int i=0, j=LiuNianArr.length; i<j; i++) {LiuNian liuNian = LiuNianArr[i];System.out.println("流年[" + i + "] = " + liuNian.getYear() + "年 " + liuNian.getAge() + "岁 " + liuNian.getGanZhi());}
output
Other examples:
年历
月历
Tung Shing
Tung Shing You can read more on your own.