Here you can find the source of truncateHour(Calendar c)
public static Calendar truncateHour(Calendar c)
//package com.java2s; //License from project: Apache License import java.util.Calendar; import java.util.Date; import java.util.GregorianCalendar; public class Main { public static Calendar truncateHour(Calendar c) { c.set(Calendar.MINUTE, 0); c.set(Calendar.SECOND, 0); c.set(Calendar.MILLISECOND, 0); return c; }//from w w w .jav a 2 s . co m public static Date truncateHour(Date d) { return toDate(truncateHour(toCalendar(d))); } public static Date toDate(Calendar calendar) { return calendar.getTime(); } public static Date toDate(long millis) { return new Date(millis); } public static Calendar toCalendar(Date date) { Calendar c = new GregorianCalendar(); c.setTime(date); return c; } public static Calendar toCalendar(long millis) { Calendar cal = new GregorianCalendar(); cal.setTime(new Date(millis)); return cal; } }