get Minutes Between Dates - Java java.util

Java examples for java.util:Minute

Description

get Minutes Between Dates

Demo Code


//package com.java2s;

import java.util.Date;

public class Main {
    public static void main(String[] argv) throws Exception {
        Date date = new Date();
        Date date2 = new Date();
        System.out.println(getMinutesBetweenDates(date, date2));
    }//from ww  w .j a  v  a2s.  c  om

    public static int getMinutesBetweenDates(Date date, Date date2) {
        Long dif = (date2.getTime() - date.getTime()) / 1000 / 60;
        return dif.intValue();
    }
}

Related Tutorials