Here you can find the source of trimToDay(Calendar calendar)
Parameter | Description |
---|---|
calendar | a calendar to trim. |
public static Calendar trimToDay(Calendar calendar)
//package com.java2s; /*/* w w w. j av a 2 s . co m*/ * Copyright (c) 2015-2016 QuartzDesk.com. * Licensed under the MIT license (https://opensource.org/licenses/MIT). */ import java.util.Calendar; public class Main { /** * Trims the specified calendar to the day by resetting the following attributes: * <ul> * <li>hour of day</li> * <li>minutes</li> * <li>seconds</li> * <li>milliseconds</li> * </ul> * The passed calendar is not modified by this method. * * @param calendar a calendar to trim. * @return the trimmed calendar. */ public static Calendar trimToDay(Calendar calendar) { Calendar cloneCal = (Calendar) calendar.clone(); cloneCal.set(Calendar.HOUR_OF_DAY, 0); cloneCal.set(Calendar.MINUTE, 0); cloneCal.set(Calendar.SECOND, 0); cloneCal.set(Calendar.MILLISECOND, 0); return cloneCal; } }