计算两个日期相隔的天数(jodd)
2024-10-18 22:27:34
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;
}
最新文章
- 9.JAVA之GUI编程列出指定目录内容
- js前端模块化之加载器原理解析(一)
- Linux sendmail发送邮件失败诊断案例(一)
- Ubuntu里的若干问题解决方案
- Linux搭建DNS服务器
- python :eval将字符串转换成字典
- ios下input focus弹出软键盘造成fixed元素位置移位
- SQL 中having 和where的区别分析
- 移动UI自动化-Page Objects Pattern
- UNIX网络编程--IPV4 IPV6 ICMPV4 ICMPV6
- hdu 5313 Bipartite Graph(dfs染色 或者 并查集)
- [iOS]C语言技术视频-05-程序循环结构(do{}while();)
- 如何从RxJava升级到RxJava2
- tkinter 创建登陆注册界面
- MS SQL 锁与事务
- js重点--原型链继承详解
- IntelliJ IDEA下SVN的配置及使用说明
- gdb 调试 python
- winform自动更新之AutoUpdater.NET
- Canonical form
热门文章
- pfx 转 snk
- POJ 3080 (字符串水题) Blue Jeans
- erl0003-ets 几种类型的区别和ets效率建议 <;转>;
- delphi 当月的第一天, 当月的最后一天
- util-判断当前年份所处的季度,并返回当前季度开始的月份
- 【PHP】Windows环境Hello World
- [原创]谷歌插件 - YE启动助手(YeLauncher)
- 将iOS中Safari 的默认搜索引擎由google.cn改为google.com的方法
- HTML5的manifest缓存
- 利用flashback query 恢复表数据