Java Day End getNumberOfDaysBetweenDates(Date beginDate, Date endDate)

Here you can find the source of getNumberOfDaysBetweenDates(Date beginDate, Date endDate)

Description

get Number Of Days Between Dates

License

Open Source License

Declaration

public static Integer getNumberOfDaysBetweenDates(Date beginDate, Date endDate) 

Method Source Code

//package com.java2s;
/**/* w ww  .j  a va2 s  .co  m*/
 * Copyright ? 2002 Instituto Superior T?cnico
 *
 * This file is part of FenixEdu Core.
 *
 * FenixEdu Core is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * FenixEdu Core is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with FenixEdu Core.  If not, see <http://www.gnu.org/licenses/>.
 */

import java.util.Calendar;
import java.util.Date;

public class Main {
    public static Integer getNumberOfDaysBetweenDates(Date beginDate, Date endDate) {
        Calendar c1 = Calendar.getInstance();
        Calendar c2 = Calendar.getInstance();

        c1.setTime(beginDate);
        c2.setTime(endDate);

        long timeBetweenInMillis = c2.getTimeInMillis() - c1.getTimeInMillis();
        Integer numberDaysBetweenDates = new Integer(new Long(timeBetweenInMillis / (3600000 * 24)).intValue());

        return numberDaysBetweenDates;
    }
}

Related

  1. getMonthSpan(Date begin, Date end)
  2. getMonthSpan(Date start, Date end)
  3. getMsBetween(Date startDate, Date endDate)
  4. getNextEndDate(Date date, int offset)
  5. getNextSendTime(Date sendDate, Date start)
  6. getNumberOfMonthsBetween(final Date begin, final Date end)
  7. getNumMonths(Date dStart, Date dEnd)
  8. getNumYears(Date dStart, Date dEnd)
  9. getSCDEndDate()