Here you can find the source of getCalendarAtMidnight(Date d)
public static Calendar getCalendarAtMidnight(Date d)
//package com.java2s; /**//ww w .j av a 2 s.c o m * Utils class for the stats * S23Y (2015). Licensed under the Apache License, Version 2.0. * Author: Thibaud Ledent */ import java.util.Calendar; import java.util.Date; public class Main { /** * Set the given date to a Calendar at midnight. * For example, if we have Thursday 9th April at 11:00 PM, it will return Thursday 9th April at 00:00 AM * @return today's Calendar at midnight. */ public static Calendar getCalendarAtMidnight(Date d) { Calendar cal = date2Calendar(d); cal.set(Calendar.HOUR_OF_DAY, 0); cal.set(Calendar.MINUTE, 0); cal.set(Calendar.SECOND, 0); cal.set(Calendar.MILLISECOND, 0); return cal; } public static Calendar date2Calendar(Date date) { Calendar cal = Calendar.getInstance(); cal.setTime(date); return cal; } }