Here you can find the source of getHour(Date now)
public static int getHour(Date now)
//package com.java2s; //License from project: Open Source License import java.util.Calendar; import java.util.Date; public class Main { public static int getHour(Date now) { Calendar calendar = getCalendarFromDate(now); return calendar.get(Calendar.HOUR_OF_DAY); }/*from w w w.ja v a 2s . 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; } }