Here you can find the source of getHour()
public static int getHour()
//package com.java2s; import java.util.Calendar; import java.util.Date; import java.util.GregorianCalendar; public class Main { public static int getHour() { Calendar cpcalendar = new GregorianCalendar(); cpcalendar.setTime(getDate());//from w w w . ja v a2s. co m return cpcalendar.get(Calendar.HOUR_OF_DAY); } public static int getHour(Date date) { Calendar cpcalendar = new GregorianCalendar(); cpcalendar.setTime(date); return cpcalendar.get(Calendar.HOUR_OF_DAY); } public static int getHour(long date) { return getHour(getDate(date)); } public static Date getDate() { return Calendar.getInstance().getTime(); } public static Date getDate(long l) { return new Date(l); } public static Date getDate(Date date, long lauchtime) { return new Date(date.getTime() + lauchtime); } public static long getTime() { return Calendar.getInstance().getTimeInMillis(); } }