Here you can find the source of getMidNightTime()
public static Date getMidNightTime()
//package com.java2s; /******************************************************************************* * Copyright Duke Comprehensive Cancer Center and SemanticBits * /*from w w w . ja v a2 s . c om*/ * Distributed under the OSI-approved BSD 3-Clause License. * See http://ncip.github.com/c3pr/LICENSE.txt for details. ******************************************************************************/ import java.sql.Time; import java.util.Calendar; import java.util.Date; public class Main { public static Date getMidNightTime() { java.util.Calendar cal = new java.util.GregorianCalendar(); cal.add(Calendar.DATE, 1); 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(); } public static Time getTime(Date date) { return new Time(date.getTime()); } }