Here you can find the source of getStartOfDay(Date day)
public static Date getStartOfDay(Date day)
//package com.java2s; import java.util.Calendar; import java.util.Date; public class Main { public static Date getStartOfDay(Date day) { Calendar calendar = Calendar.getInstance(); calendar.setTime(day);// w ww . j ava 2 s .c om calendar.set(Calendar.HOUR_OF_DAY, 0); calendar.set(Calendar.MINUTE, 0); calendar.set(Calendar.SECOND, 0); calendar.set(Calendar.MILLISECOND, 0); return calendar.getTime(); } public static Date set(Date date, int calendarFiled, int amount) { if (null == date) { throw new IllegalArgumentException("The date must not be null"); } else { } Calendar c = Calendar.getInstance(); c.setTime(date); c.set(calendarFiled, amount); return c.getTime(); } }