本文主要是介绍Java实现农历转化阳历,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
首先加入Maven依赖
<dependency><groupId>cn.6tail</groupId><artifactId>lunar</artifactId><version>1.3.9</version> </dependency>
示例代码:
public static void main(String[] args) {// 实例化Lunar lunar = Lunar.fromYmd(2023, 11, 8);System.out.println(lunar); //农历 二〇二三年冬月初八// 转阳历Solar solar = lunar.getSolar();System.out.println(solar.toString()); //阳历 2023-12-20System.out.println(solar.toFullString()); //2023-12-20 00:00:00 星期三 射手座Lunar d = Lunar.fromDate(new Date());System.out.println(d);System.out.println(d.toFullString());System.out.println(d.getYear());System.out.println(d.getMonth());System.out.println(d.getDay());System.out.println(d.getYearInChinese());System.out.println(d.getMonthInChinese());System.out.println(d.getDayInChinese());}
效果图:
这篇关于Java实现农历转化阳历的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!