java函_JavaChineseCalendar─能讓Java支援農曆曆法的Java函式庫

雖然Java 8之後的日期函式庫能夠支援多種曆法,但是中國的農曆還是尚未被納入支援範圍。如果要在Java使用農曆曆法,可以使用「JavaChineseCalendar」這個Java函式庫。JavaChineseCalendar支援農曆和西曆日期的轉換,時間可從西曆的西元1901年2月19日支援到2100年12月31日。另外,它還能計算生辰八字的重量。

下載JavaChineseCalendar

使用JavaChineseCalendar

JavaChineseCalendar除了可以當作一般Java函式庫來被其他Java程式引用外,還可以作為一個可獨立執行的Program,提供命令列介面將西曆轉換成農曆。

使用者可以在用命令列執行JavaChineseCalendar的同時,傳入西曆的年月日參數。命令列的指令格式如下: java -jar JavaChineseCalendar.jar [YYYY MM DD]

1c4a79493774f9a7c54b7ed5449acd9a.png

順道一提,如果您參閱JavaChineseCalendar的原始碼,可以發現原始碼有許多使用中文命名的類別、變數和方法,真的是滿滿的中國風味呀~

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
# Class **** class is in the *org.magiclen.* package. ### Initialize You can't create a **** instance by using **new** operator directly. You have to use the **建立** static method provided by **** class to create a **** instance. You can pass the year, month and the days of the month in Gregorian calendar as parameters to **建立** method. For example, we want to create a **** object instance with the date 2015-12-16 in Gregorian calendar. The code will be, .建立(2015, 12, 12); For example, we want to create a **** object instance with the date 2015-12-16 in Chinese calendar and we know that date is not in a leap month. The code will be, date = .建立(2015, 12, false, 12); ### Get the date in Gregorian calendar Use **取得西** method to get the date in Gregorian calendar. String gregorianDate = date.取得西(); ### Get the date in Chinese calendar Use **取得** method to get the date in Chinese calendar. String chineseDate = date.取得(); ### Compute the weight of Ba Zi(八字) Use **計算八字有幾兩重** method to compute the weight of Ba Zi. Because **** object has no hour information, if you want to compute the weight of Ba Zi, you have to provide the hour information in the form of the twelve Earthly Branches. float BaZiWeight = date.計算八字有幾兩重(.地支.子); # Run **Java Chinese Calendar** as a program You can also use the two commands below to run **Java Chinese Calendar**: java -jar JavaChineseCalendar.jar It will show today's date in Gregorian calendar and Chinese calendar. The result just likes 西:2015-12-16 :2015(乙未、羊年) 冬月 初六 Yo
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值