Here you can find the source of elapsedHours(Calendar aFirstDate, Calendar aSecondDate)
public static long elapsedHours(Calendar aFirstDate, Calendar aSecondDate)
//package com.java2s; //License from project: Open Source License import java.util.Calendar; public class Main { public static long elapsedHours(Calendar aFirstDate, Calendar aSecondDate) { return Math.abs(millisToHours(aSecondDate.getTimeInMillis() - aFirstDate.getTimeInMillis())); }//from ww w . java 2 s .c o m private static long millisToHours(long millis) { return millis / 1000 / 60 / 60; } }