Here you can find the source of removeTime(final Calendar date)
Parameter | Description |
---|---|
date | The date that you wish to remove the time portions from. |
public static Calendar removeTime(final Calendar date)
//package com.java2s; // Licensed under the MIT license. See License.txt in the repository root. import java.util.Calendar; public class Main { /**/*from w w w . j a v a2 s .c om*/ * Remote the time elements of the passed {@link Calendar}, setting the time * to midnight of that day. Note: This function will affect the date passed * as well as returning the same date. If you do not wish this method to * affect the date passed then you should clone it before passing. * * @param date * The date that you wish to remove the time portions from. * @return the same {@link Calendar} istance passed, with the time fields * now set to 0. */ public static Calendar removeTime(final Calendar date) { date.set(Calendar.SECOND, 0); date.set(Calendar.MINUTE, 0); date.set(Calendar.HOUR, 0); date.set(Calendar.HOUR_OF_DAY, 0); date.set(Calendar.MILLISECOND, 0); // Note that this line is needed due to a strange issue in Gregorian // Calendar. // If this is not done then subsequent additions to the time etc can be // ignored. date.getTimeInMillis(); return date; } }