/**
* 获得两个日期间距多少天
*
* @param beginDate
* @param endDate
* @return
*/
public static long getTimeDistance(Date beginDate, Date endDate) {
Calendar fromCalendar = Calendar.getInstance();
fromCalendar.setTime(beginDate);
fromCalendar.set(Calendar.HOUR_OF_DAY, fromCalendar.getMinimum(Calendar.HOUR_OF_DAY));
fromCalendar.set(Calendar.MINUTE, fromCalendar.getMinimum(Calendar.MINUTE));
fromCalendar.set(Calendar.SECOND, fromCalendar.getMinimum(Calendar.SECOND));
fromCalendar.set(Calendar.MILLISECOND, fromCalendar.getMinimum(Calendar.MILLISECOND));
Calendar toCalendar = Calendar.getInstance();
toCalendar.setTime(endDate);
toCalendar.set(Calendar.HOUR_OF_DAY, fromCalendar.getMinimum(Calendar.HOUR_OF_DAY));
toCalendar.set(Calendar.MINUTE, fromCalendar.getMinimum(Calendar.MINUTE));
toCalendar.set(Calendar.SECOND, fromCalendar.getMinimum(Calendar.SECOND));
toCalendar.set(Calendar.M
Android获取两个日期的天数差、周数差、月数差
最新推荐文章于 2021-05-31 14:42:26 发布
本文介绍如何在Android中计算两个日期之间的天数差、周数差和月数差,详细讲解了相关的方法和代码实现,帮助开发者处理日期相关的计算问题。
摘要由CSDN通过智能技术生成