public static void main(String[] args) throws ParseException {
System.out.println(TimeUtil.dayOfYear(1992, 12, 31));
System.out.println(TimeUtil.dayOfYear(2016, 3, 14)); JDateTime time = new JDateTime(new Date());
JDateTime time2 = new JDateTime(new SimpleDateFormat("yyyyMMdd").parse("20160310")); System.out.println(time2.daysBetween(time));
}
daysBetween源码分析
/**
* Calculates the number of days between two dates. Returned value is always positive.
*/
public int daysBetween(JulianDateStamp otherDate) {
int difference = daysSpan(otherDate);
return difference >= 0 ? difference : -difference;
} /**
* Returns span between two days. Returned value may be positive (when this date
* is after the provided one) or negative (when comparing to future date).
*/
public int daysSpan(JulianDateStamp otherDate) {
int now = getJulianDayNumber();
int then = otherDate.getJulianDayNumber();
return now - then;
} /**
* Returns JDN. Note that JDN is not equal to {@link #integer}. It is calculated by
* rounding to the nearest integer.
*/
public int getJulianDayNumber() {
if (fraction >= 0.5) {
return integer + 1;
}
return integer;
}
 

最新文章

  1. 9.JAVA之GUI编程列出指定目录内容
  2. js前端模块化之加载器原理解析(一)
  3. Linux sendmail发送邮件失败诊断案例(一)
  4. Ubuntu里的若干问题解决方案
  5. Linux搭建DNS服务器
  6. python :eval将字符串转换成字典
  7. ios下input focus弹出软键盘造成fixed元素位置移位
  8. SQL 中having 和where的区别分析
  9. 移动UI自动化-Page Objects Pattern
  10. UNIX网络编程--IPV4 IPV6 ICMPV4 ICMPV6
  11. hdu 5313 Bipartite Graph(dfs染色 或者 并查集)
  12. [iOS]C语言技术视频-05-程序循环结构(do{}while();)
  13. 如何从RxJava升级到RxJava2
  14. tkinter 创建登陆注册界面
  15. MS SQL 锁与事务
  16. js重点--原型链继承详解
  17. IntelliJ IDEA下SVN的配置及使用说明
  18. gdb 调试 python
  19. winform自动更新之AutoUpdater.NET
  20. Canonical form

热门文章

  1. pfx 转 snk
  2. POJ 3080 (字符串水题) Blue Jeans
  3. erl0003-ets 几种类型的区别和ets效率建议 <转>
  4. delphi 当月的第一天, 当月的最后一天
  5. util-判断当前年份所处的季度,并返回当前季度开始的月份
  6. 【PHP】Windows环境Hello World
  7. [原创]谷歌插件 - YE启动助手(YeLauncher)
  8. 将iOS中Safari 的默认搜索引擎由google.cn改为google.com的方法
  9. HTML5的manifest缓存
  10. 利用flashback query 恢复表数据