between Days from two Dates - Android java.util

Android examples for java.util:Date Compare

Description

between Days from two Dates

Demo Code


//package com.java2s;

import java.util.Date;

public class Main {
    public static final long DAY_MS = 24 * 3600 * 1000;

    public static int betweenDays(Date date1, Date date2) {

        return (int) (betweenmillonsecond(date1, date2) / DAY_MS);
    }//w w  w  . j  a  v a  2 s .c o m

    public static long betweenmillonsecond(Date date1, Date date2) {
        long day2 = date2.getTime();
        long day1 = date1.getTime();
        long betweenseconds = Math.abs(day2 - day1);
        return betweenseconds;
    }
}

Related Tutorials