Here you can find the source of midnight(Date date, TimeZone tz)
public static Date midnight(Date date, TimeZone tz)
//package com.java2s; //License from project: Apache License import java.util.Calendar; import java.util.Date; import java.util.GregorianCalendar; import java.util.TimeZone; public class Main { /**//from www . jav a 2 s. com * Calculates midnight of the day in which date lies with respect * to a time zone. **/ public static Date midnight(Date date, TimeZone tz) { Calendar cal = new GregorianCalendar(tz); cal.setTime(date); cal.set(Calendar.HOUR_OF_DAY, 0); cal.set(Calendar.MINUTE, 0); cal.set(Calendar.SECOND, 0); cal.set(Calendar.MILLISECOND, 0); return cal.getTime(); } }