提取两个时间点的天数差

这个Java代码实现了一个DateUtils类,用于计算两个日期之间的天数差。它使用Calendar对象作为输入,通过比较年份和月份计算日期差。代码中还包括一个内部类DayDate,用于表达日期并进行相等比较。
摘要由CSDN通过智能技术生成
作者:郝春利
转贴请注明出处: http://blog.csdn.net/froole

提取两个时间点的天数差——看上去一个及其单纯的问题,但是,考虑到不同年份、闰年等因素,想要写一个可以广泛使用的却非常麻烦。
以下是loveapple工程中我写的一个提取不同时间点的天数的代码,如有不足,希望各路大虾指正。


  1. /*
  2.  * $Header$
  3.  * $Author$
  4.  * $Revision$
  5.  * $Date$
  6.  *
  7.  * ====================================================================
  8.  *
  9.  * Copyright (C) 2008 by www.loveapple.cn
  10.  *
  11.  * All copyright notices regarding loveapple and loveapple CoreLib
  12.  * MUST remain intact in the scripts, documents and source code.
  13.  *
  14.  * This library is free software; you can redistribute it and/or
  15.  * modify it under the terms of the GNU Lesser General Public
  16.  * License as published by the Free Software Foundation; either
  17.  * version 3 of the License, or (at your option) any later version.
  18.  *
  19.  * This library is distributed in the hope that it will be useful,
  20.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  21.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  22.  * Lesser Gene
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值