6tail / lunar-java

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

java公历转农历速度有点慢 #35

Open Maikscau opened 1 year ago

Maikscau commented 1 year ago

我把一个月的公历的全部日子都转换为农历,发现大概需要1.5-2秒,感觉有点慢,不知道是不是使用的方式不对? 语法是kotlin,我单独测试过Date.from(day.atStartOfDay().atZone(ZoneId.systemDefault()).toInstant())这个是不耗时的

val lunarDate = Lunar.fromDate(Date.from(day.atStartOfDay().atZone(ZoneId.systemDefault()).toInstant()))
val subText = if (lunarDate.day == 1) {
    lunarDate.monthInChinese + "月"
} else {
    lunarDate.dayInChinese
}
6tail commented 3 months ago

tyme速度快得多,可以试下。 https://github.com/6tail/tyme4j