Java tutorial
import java.util.Calendar; import java.util.Date; public class Main { public static void main(String[] args) { System.out.println(round2Hour(new Date())); } public static Date round2Hour(Date date) { Calendar cal = Calendar.getInstance(); cal.setTime(date); cal.set(Calendar.MINUTE, 0); cal.set(Calendar.SECOND, 0); cal.set(Calendar.MILLISECOND, 0); return cal.getTime(); } }