Here you can find the source of betweenHour(Date date, int hour)
public static boolean betweenHour(Date date, int hour)
//package com.java2s; //License from project: Open Source License import java.util.Calendar; import java.util.Date; public class Main { public static boolean betweenHour(Date date, int hour) { Calendar calendar = getCalendarFromDate(date); calendar.add(Calendar.HOUR, hour); Calendar now = getDefaultCalendar(); return calendar.after(now); }//from ww w .j a v a 2 s . c o m /** * get calendar from date * * @param date the passing date * @return the calendar instance */ public static Calendar getCalendarFromDate(Date date) { Calendar calendar = getDefaultCalendar(); calendar.setTime(date); return calendar; } /** * get the default calendar * * @return the calendar instance */ public static Calendar getDefaultCalendar() { Calendar calendar = Calendar.getInstance(); calendar.setFirstDayOfWeek(Calendar.MONDAY); return calendar; } }