Here you can find the source of beginOfDay(Date date)
public static Date beginOfDay(Date date)
//package com.java2s; //License from project: Open Source License import java.sql.Timestamp; import java.util.Calendar; import java.util.Date; public class Main { public static Date beginOfDay(Date date) { Calendar c = Calendar.getInstance(); c.setTime(date);//from w w w. jav a 2s . c o m c.set(c.get(Calendar.YEAR), c.get(Calendar.MONTH), c.get(Calendar.DAY_OF_MONTH), 0, 0, 0); c.set(Calendar.MILLISECOND, 0); return c.getTime(); } public static Timestamp beginOfDay(Timestamp timestamp) { Calendar c = Calendar.getInstance(); c.setTime(timestamp); c.set(c.get(Calendar.YEAR), c.get(Calendar.MONTH), c.get(Calendar.DAY_OF_MONTH), 0, 0, 0); c.set(Calendar.MILLISECOND, 0); return new Timestamp(c.getTimeInMillis()); } }