Here you can find the source of clearTime(final Calendar c)
0
.
Parameter | Description |
---|---|
c | the Calendar . |
public static void clearTime(final Calendar c)
//package com.java2s; /******************************************************************************* * Copyright (c) 2013, 2014, 2015 QPark Consulting S.a r.l. * /*www .j a va 2s .com*/ * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0. * The Eclipse Public License is available at * http://www.eclipse.org/legal/epl-v10.html. ******************************************************************************/ import java.util.Calendar; import java.util.Date; public class Main { /** * Set {@link Calendar#HOUR_OF_DAY}, {@link Calendar#MINUTE}, * {@link Calendar#SECOND} and {@link Calendar#MILLISECOND} to * <code>0</code>. * * @param c * the {@link Calendar}. */ public static void clearTime(final Calendar c) { if (c != null) { c.set(Calendar.HOUR_OF_DAY, 0); c.set(Calendar.MINUTE, 0); c.set(Calendar.SECOND, 0); c.set(Calendar.MILLISECOND, 0); } } /** * Returns a date with hour, minute, second and millisecond set to * <code>0</code>. * * @param d * the {@link Date} with hour, minute, second and millisecond * set. * @return the {@link Date} with cleared time. */ public static Date clearTime(final Date d) { if (d != null) { Calendar c = Calendar.getInstance(); c.setTime(d); clearTime(c); return c.getTime(); } else { return d; } } }