spring boot lunar 农历的三方库引用,获取日期的农历值
1、官方地址
lunar
版本比较全,各种都有。
2、引入pom.xml
<dependency><groupId>cn.6tail</groupId><artifactId>lunar</artifactId><version>1.7.4</version></dependency>
3、导入包
import com.nlf.calendar.Lunar;
4、农历
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
try {Lunar lr = Lunar.fromDate(sdf.parse("2025-05-10"));String nl = lr.toString();System.out.println(nl);} catch (ParseException e) {e.printStackTrace();}
5、显示
当然这里面还有很多其它的用法,需要的话,可以自己尝试看一下官网的api,调用还是比较简单的。