get Minutes Between Two Dates - Java java.util

Java examples for java.util:Minute

Description

get Minutes Between Two Dates

Demo Code


//package com.java2s;

import java.util.Date;

public class Main {
    public static void main(String[] argv) throws Exception {
        Date start = new Date();
        Date end = new Date();
        System.out.println(getMinutesBetweenTwoDates(start, end));
    }/*from ww  w.  j a v a 2s  .  c o  m*/

    public static int getMinutesBetweenTwoDates(Date start, Date end) {
        long diff = Math.abs(end.getTime() - start.getTime());
        return (int) (diff / 1000 / 60);
    }
}

Related Tutorials