Here you can find the source of getIntervalHours(Date minDate, Date maxDate)
public static double getIntervalHours(Date minDate, Date maxDate)
//package com.java2s; import java.util.Date; public class Main { public static double getIntervalHours(Date minDate, Date maxDate) { double days = 0.0; if (minDate == null || maxDate == null) { return days; }//from ww w . j av a 2 s . c o m try { days = getIntervalMinutes(minDate, maxDate) / 60; } catch (Exception e) { e.printStackTrace(); } return days; } public static double getIntervalMinutes(Date minDate, Date maxDate) { double days = 0.0; if (minDate == null || maxDate == null) { return days; } try { long interval = maxDate.getTime() - minDate.getTime(); days = Double.valueOf(interval) / 1000 / 60; } catch (Exception e) { e.printStackTrace(); } return days; } }