Here you can find the source of getHour(Date date)
public static int getHour(Date date)
//package com.java2s; //License from project: LGPL import java.util.Calendar; import java.util.Date; public class Main { public static int getHour(Date date) { return getField(date, Calendar.HOUR); }//from w w w . jav a2s .co m public static int getField(Date date, int field) { int result = -1; if (date != null) { Calendar calendar = Calendar.getInstance(); calendar.setTime(date); result = calendar.get(field); } return result; } }