Here you can find the source of getNumDaysDiffExclTime(Date date1, Date date2)
Parameter | Description |
---|---|
date1 | a parameter |
date2 | a parameter |
public static int getNumDaysDiffExclTime(Date date1, Date date2)
//package com.java2s; /**/*w ww. j a va2s .c o m*/ * Copyright (C) 2013 Company. All Rights Reserved. * * This software is the proprietary information of Company . * Use is subjected to license terms. * * @since Jul 17, 2013 11:48:25 PM * @author SPA * */ import java.util.Calendar; import java.util.Date; import java.util.GregorianCalendar; public class Main { /** * This method returns number of days between date1 and date2, including * date1 and date2 regardless of the date time. Eg 1 Jan 06 2000hrs to 3 Jan * 06 1900hrs will return as 3 days. This method is used for * * @param date1 * @param date2 * @return */ public static int getNumDaysDiffExclTime(Date date1, Date date2) { int result = 0; Calendar cal = new GregorianCalendar(); cal.setTime(date1); while (!cal.getTime().after(date2)) { cal.add(Calendar.DAY_OF_MONTH, 1); result++; } return result; } }