Here you can find the source of convertToStartOfDay(Date date)
Parameter | Description |
---|---|
date | Any date |
public static Date convertToStartOfDay(Date date)
//package com.java2s; /******************************************************************************* * Copyright (c) 2010 Boeing./*from w w w .ja v a 2s . c om*/ * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * Boeing - initial API and implementation *******************************************************************************/ import java.util.Calendar; import java.util.Date; public class Main { /** * @param date Any date * @return The same date but with time equal to 00:00:00 */ public static Date convertToStartOfDay(Date date) { Calendar cal = Calendar.getInstance(); cal.setTime(date); cal.set(Calendar.HOUR_OF_DAY, 0); cal.set(Calendar.MINUTE, 0); cal.set(Calendar.SECOND, 0); return cal.getTime(); } }