Java tutorial
//package com.java2s; //License from project: Apache License import java.util.Date; public class Main { public static int betweenHour(Date from, Date to) { long duration = from.getTime() - to.getTime(); return (int) (duration / (1000 * 60 * 60)); } }