Android Date Interval Get getIntervalDays(Date minDate, Date maxDate)

Here you can find the source of getIntervalDays(Date minDate, Date maxDate)

Description

get Interval Days

Declaration

public static double getIntervalDays(Date minDate, Date maxDate) 

Method Source Code

//package com.java2s;

import java.util.Date;

public class Main {
    public static double getIntervalDays(Date minDate, Date maxDate) {
        double days = 0;
        if (minDate == null || maxDate == null) {
            return days;
        }//from w  w w. ja v a 2  s  .  c  o m
        try {
            days = getIntervalHours(minDate, maxDate) / 24;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return days;
    }

    public static double getIntervalHours(Date minDate, Date maxDate) {
        double days = 0.0;
        if (minDate == null || maxDate == null) {
            return days;
        }
        try {
            days = getIntervalMinutes(minDate, maxDate) / 60;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return days;
    }

    public static double getIntervalMinutes(Date minDate, Date maxDate) {
        double days = 0.0;
        if (minDate == null || maxDate == null) {
            return days;
        }
        try {
            long interval = maxDate.getTime() - minDate.getTime();
            days = Double.valueOf(interval) / 1000 / 60;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return days;
    }
}

Related

  1. getFragment(Calendar calendar, int fragment, int unit)
  2. getFragment(Date date, int fragment, int unit)
  3. getFragmentInDays(Date date, int fragment)
  4. getFragmentInHours(Date date, int fragment)
  5. getInterval(String beginMonth, String endMonth)
  6. getIntervalDays(String sd, String ed)
  7. getIntervalHours(Date minDate, Date maxDate)
  8. getIntervalMinutes(Date minDate, Date maxDate)
  9. getIntervalYears(Date date1, Date date2)