days Between two date - Java java.util

Java examples for java.util:Day

Description

days Between two date

Demo Code


//package com.java2s;

import java.util.Date;

import java.util.concurrent.TimeUnit;

public class Main {
    public static int daysBetween(Date date1, Date date2) {
        long timespan = date2.getTime() - date1.getTime();
        return (int) TimeUnit.DAYS.convert(timespan, TimeUnit.MILLISECONDS);
    }//from  w  ww  .j a va2 s . c  o  m
}

Related Tutorials