Scala/Java日期處理庫:Lamma
Java / Scala的日期生成終極解決方案。提供一組簡單易用的 API 來做基本的日期處理和復雜任務調度。
基本的日期操作:new Date(2014, 7, 2).plusDays(3); // result: Date(2014, 7, 5)
new Date(2014, 7, 8).minus(new Date(2014, 7, 2)); // result: 6
new Date(2014, 7, 8).isAfter(new Date(2014, 7, 2)); // result: true</pre>高級日期生成:</h3>
生成從2014年12月1日至2014年12月31日每5天的列表,除了周末。
Dates.from(2014, 11, 1).to(2014, 12, 31).byDays(10).except(HolidayRules.weekends()).build();
Result:
// Date(2014,12,6) and Date(2014,12,21) are not in the list because they are weekends.
List(Date(2014,12,1), Date(2014,12,11), Date(2014,12,16), Date(2014,12,26), Date(2014,12,31))
new Date(2014, 7, 8).minus(new Date(2014, 7, 2)); // result: 6
new Date(2014, 7, 8).isAfter(new Date(2014, 7, 2)); // result: true</pre>高級日期生成:</h3> 生成從2014年12月1日至2014年12月31日每5天的列表,除了周末。
Dates.from(2014, 11, 1).to(2014, 12, 31).byDays(10).except(HolidayRules.weekends()).build();
Result:
// Date(2014,12,6) and Date(2014,12,21) are not in the list because they are weekends. List(Date(2014,12,1), Date(2014,12,11), Date(2014,12,16), Date(2014,12,26), Date(2014,12,31))
本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!