Java Calendar Different getDaysDifference(Calendar refDate, Date date)

Here you can find the source of getDaysDifference(Calendar refDate, Date date)

Description

get Days Difference

License

Mozilla Public License

Declaration

public static int getDaysDifference(Calendar refDate, Date date) 

Method Source Code

//package com.java2s;
/* This file is part of the MayDesk project.
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. 
 * Software distributed under the License is distributed on an "AS IS" basis,
 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
 * for the specific language governing rights and limitations under the
 * License.*//*from w  ww  .  ja  v  a  2  s .  co  m*/

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

public class Main {
    public static long MILLIS_PER_DAY = 24 * 60 * 60 * 1000;

    public static int getDaysDifference(Calendar refDate, Date date) {
        long delta = date.getTime() - refDate.getTimeInMillis();
        long deltaDays = (delta) / MILLIS_PER_DAY;
        return (int) deltaDays;
    }
}

Related

  1. differenceInDays(Calendar date1, Calendar date2)
  2. formatTimeDiff(Calendar ref, Calendar now, boolean ignoreMS)
  3. getDateDiff(Calendar c1, Calendar c2)
  4. getDateDiff(Calendar d1, Calendar d2)
  5. getDateDiff(Date d1, Date d2, int gregorianCalendarUnits)
  6. getDifference(int constant, Calendar first, Calendar second)
  7. getDifference(int field, Calendar aCalX, Calendar aCalY)
  8. getDifferenceInDays(Calendar fromDate, Calendar toDate)
  9. getDifferenceInSeconds(Calendar calendarStart, Calendar calendarEnd)