Java日期时间处理类 date4j

jopen 13年前
     <p>date4j是一个用于简化日期和时间操作的Java工具。可以替换java.util.Date。</p>    <p>示例代码:</p>    <pre class="brush:cpp; toolbar: true; auto-links: false;">DateTime dateAndTime = new DateTime("2010-01-19 23:59:59"); DateTime dateAndTime = new DateTime("2010-01-19 23:59:59.123456789"); DateTime dateOnly = new DateTime("2010-01-19"); DateTime timeOnly = new DateTime("23:59:59"); DateTime dateOnly = DateTime.forDateOnly(2010,01,19); DateTime timeOnly = DateTime.forTimeOnly(23,59,59,0);  DateTime dt = new DateTime("2010-01-15 13:59:15"); boolean leap = dt.isLeapYear(); //false dt.getNumDaysInMonth(); //31 dt.getStartOfMonth(); //2010-01-01, 00:00:00.000000000 dt.getEndOfDay(); //2010-01-15, 23:59:59.999999999 dt.format("YYYY-MM-DD"); //formats as '2010-01-15' dt.plusDays(30); //30 days after Jan 15 dt.numDaysFrom(someDate); //returns an int dueDate.lt(someDate); //less-than dueDate.lteq(someDate); //less-than-or-equal-to</pre>    <p></p>    <p><strong>项目主页:</strong><a href="http://www.open-open.com/lib/view/home/1324995649655" target="_blank">http://www.open-open.com/lib/view/home/1324995649655</a></p>