Here you can find the source of isAfterHour(Date source, int hour)
public static boolean isAfterHour(Date source, int hour)
//package com.java2s; /**// ww w . j a v a 2 s. co m * Project: guahao-portal-web-home * * File Created at 2012-9-26 * * Copyright 2012 Greenline.com Corporation Limited. * All rights reserved. * * This software is the confidential and proprietary information of * Greenline Company. ("Confidential Information"). You shall not * disclose such Confidential Information and shall use it only in * accordance with the terms of the license agreement you entered into * with Greenline.com. */ import java.util.Calendar; import java.util.Date; public class Main { public static boolean isAfterHour(Date source, int hour) { Calendar c = Calendar.getInstance(); c.setTime(source); int hourOfDay = c.get(Calendar.HOUR_OF_DAY); if (hourOfDay - hour >= 0) { return true; } else { return false; } } }