hours Between - Java java.util

Java examples for java.util:Hour

Description

hours Between

Demo Code


//package com.java2s;

import java.util.Date;

public class Main {
    public static double hoursBetween(Date date1, Date date2) {
        return minutesBetween(date1, date2) / 60;
    }//from   w  w w.  j av  a  2s .  c  o  m

    public static double minutesBetween(Date date1, Date date2) {
        long gapInMilliseconds = date2.getTime() - date1.getTime();
        return Math.abs(gapInMilliseconds / (double) (1000 * 60));
    }
}

Related Tutorials