Here you can find the source of hoursBetween(Calendar startDate, Calendar endDate)
public static long hoursBetween(Calendar startDate, Calendar endDate)
//package com.java2s; //License from project: Apache License import java.util.Calendar; public class Main { public static long hoursBetween(Calendar startDate, Calendar endDate) { Calendar date = (Calendar) startDate.clone(); long hoursBetween = -1; while (date.before(endDate) || date.equals(endDate)) { date.add(Calendar.HOUR, 1); hoursBetween++;/*from ww w .j av a 2 s . c om*/ } return hoursBetween; } }