Java Calendar Day setToBeginningOfDay(Calendar cal)

Here you can find the source of setToBeginningOfDay(Calendar cal)

Description

This method will set the calenders hour/min/sec//milliseconds all to 0.

License

Open Source License

Declaration

public static Calendar setToBeginningOfDay(Calendar cal) 

Method Source Code

//package com.java2s;
/**// w w  w .ja va 2s .com
 *
 * Copyright (c) 2005-2012. Centre for Research on Inner City Health, St. Michael's Hospital, Toronto. All Rights Reserved.
 * This software is published under the GPL GNU General Public License.
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * 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 Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 *
 * This software was written for
 * Centre for Research on Inner City Health, St. Michael's Hospital,
 * Toronto, Ontario, Canada
 */

import java.util.Calendar;

public class Main {
    /**
     * This method will set the calenders hour/min/sec//milliseconds all to 0.
     */
    public static Calendar setToBeginningOfDay(Calendar cal) {
        cal.set(Calendar.HOUR_OF_DAY, 0);
        cal.set(Calendar.MINUTE, 0);
        cal.set(Calendar.SECOND, 0);
        cal.set(Calendar.MILLISECOND, 0);

        // force calculation / materialisation of actual time.
        cal.getTimeInMillis();

        return (cal);
    }
}

Related

  1. sameDay(Calendar one, Calendar two)
  2. setDayToCalendar(int days, Calendar calendar)
  3. setEndDay(Calendar cal)
  4. setStartOfDay(final Calendar calendar)
  5. setStartTimeOfDay(Calendar calender)
  6. setToStartOfDay(Calendar start)
  7. setToStartTimeOfTheDay(Calendar c)
  8. startOfDay(Calendar calendar)
  9. toCountWorkDays(GregorianCalendar start, GregorianCalendar end)