6tail / lunar-java

日历、公历(阳历)、农历(阴历、老黄历)、佛历、道历,支持节假日、星座、儒略日、干支、生肖、节气、节日、彭祖百忌、每日宜忌、吉神宜趋凶煞宜忌、吉神(喜神/福神/财神/阳贵神/阴贵神)方位、胎神方位、冲煞、纳音、星宿、八字、五行、十神、建除十二值星、青龙名堂等十二神、黄道日及吉凶等。lunar is a calendar library for Solar and Chinese Lunar.
http://6tail.cn/calendar/api.html
MIT License
667 stars 152 forks source link

月日的干支都错了 #27

Open JasonBourne33 opened 1 year ago

JasonBourne33 commented 1 year ago

月日的干支都错了,正确应该是 壬寅年 辛亥月 甲申日 image image image

bigbiglemon commented 1 year ago

@JasonBourne33 你用的方法是“传入指定农历年月日获取农历”,所以你得到了冬月二七的干支…… 而你提到的正确干支是公历11月27的 -----来自长期使用该库,并定期的来更新的一位开发

6tail commented 1 year ago

楼上的朋友指出问题关键,你用错方法了,请注意看下文档。 @JasonBourne33

JasonBourne33 commented 1 year ago

可以了,谢谢,应该这样用 image

6tail commented 1 year ago

@JasonBourne33 不建议这样重复多次调用solar.getLunar(),每调用一次getLunar(),都会重新计算一次,运行效率太低。应该这样使用:

Solar solar = Solar.fromYmdHms(year, month, day, hour, 0, 0);
Lunar lunar = solar.getLunar();
String yearInGanZhi = lunar.getYearInGanZhi();
String monthInGanZhi = lunar.getMonthInGanZhi();
JasonBourne33 commented 1 year ago

好的,已经改了