Java Calendar Between getDaysBetween(final Calendar start, final Calendar end)

Here you can find the source of getDaysBetween(final Calendar start, final Calendar end)

Description

get Days Between

License

Open Source License

Declaration

public static double getDaysBetween(final Calendar start,
            final Calendar end) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2009 Lifeform Software.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors://w  w w.java2 s  .  c  om
 *     Ernan Hughes - initial API and implementation
 *******************************************************************************/

import java.util.Calendar;

public class Main {
    private static final int miliPerDay = 60 * 60 * 24 * 1000;

    public static double getDaysBetween(final Calendar start,
            final Calendar end) {
        return getDaysBetween(start.getTimeInMillis(),
                end.getTimeInMillis());
    }

    public static double getDaysBetween(final long start, final long end) {
        int days = (int) ((end - start) / miliPerDay);
        return days;
    }
}

Related

  1. getDaysBetween(Calendar d1, Calendar d2)
  2. getDaysBetween(Calendar d1, Calendar d2)
  3. getDaysBetween(Calendar firstDate, Calendar lastDate)
  4. getDaysBetween(Calendar start, Calendar end)
  5. getDaysBetween(Calendar startDate, Calendar endDate)
  6. getFmtCalendar(Calendar c, long betweenTimeout, StringBuilder sb)
  7. hoursBetween(Calendar start, Calendar end, boolean assumeSameDate)
  8. hoursBetween(Calendar startDate, Calendar endDate)
  9. isBetween(Calendar time, Calendar start, Calendar end)