Here you can find the source of getHour()
public static int getHour()
//package com.java2s; //License from project: Open Source License import java.util.Calendar; import java.util.Date; import java.util.GregorianCalendar; public class Main { public static int getHour() { Calendar calendar = new GregorianCalendar(); Date trialtime = new Date(); calendar.setTime(trialtime);/*from w w w . ja va 2s. c om*/ return calendar.get(Calendar.HOUR); } }