Here you can find the source of startOfDay(Calendar calendar)
Parameter | Description |
---|---|
calendar | calendar to adjust. |
public static void startOfDay(Calendar calendar)
//package com.java2s; /*//from w w w.j a v a 2s. c o m * #%L * The AIBench Plugin Manager Plugin * %% * Copyright (C) 2006 - 2016 Daniel Glez-Pe?a and Florentino Fdez-Riverola * %% * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Lesser Public License for more details. * * You should have received a copy of the GNU General Lesser Public * License along with this program. If not, see * <http://www.gnu.org/licenses/lgpl-3.0.html>. * #L% */ import java.util.Calendar; import java.util.Date; public class Main { /** * Adjust the given calendar to the first millisecond of the given date. * that is all time fields cleared. The Date of the adjusted Calendar is * returned. * * @param calendar calendar to adjust. * @param date the Date to use. * @return the start of the day of the given date */ public static Date startOfDay(Calendar calendar, Date date) { calendar.setTime(date); startOfDay(calendar); return calendar.getTime(); } /** * Adjust the given calendar to the first millisecond of the current day. * that is all time fields cleared. * * @param calendar calendar to adjust. */ public static void startOfDay(Calendar calendar) { calendar.set(Calendar.HOUR_OF_DAY, 0); calendar.set(Calendar.MILLISECOND, 0); calendar.set(Calendar.SECOND, 0); calendar.set(Calendar.MINUTE, 0); } }