Here you can find the source of stripTimeFromDate(Date aDate)
Parameter | Description |
---|---|
aDate | the date |
public static Date stripTimeFromDate(Date aDate)
//package com.java2s; /******************************************************************************* * Copyright (c) 2013 Rene Schneider, GEBIT Solutions GmbH and others. * 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 *******************************************************************************/ import java.util.Calendar; import java.util.Date; public class Main { /**/* w w w .j a va2 s.co m*/ * Strips the time information from a given {@link Date} (sets all time fields to zero). * * @param aDate * the date * @return a new Date without time information */ public static Date stripTimeFromDate(Date aDate) { Calendar tempCalendar = Calendar.getInstance(); tempCalendar.setTime(aDate); tempCalendar.set(Calendar.HOUR_OF_DAY, 0); tempCalendar.set(Calendar.MINUTE, 0); tempCalendar.set(Calendar.SECOND, 0); tempCalendar.set(Calendar.MILLISECOND, 0); return tempCalendar.getTime(); } }