Java Calendar Time setTimeToMidnight(GregorianCalendar c)

Here you can find the source of setTimeToMidnight(GregorianCalendar c)

Description

Sets the time fields (24-hour, minute, second, millisecond) of the specified GregorianCalendar instance to 0 so it subsequently represents midnight of the same day as before.

License

Open Source License

Parameter

Parameter Description
c the instance to modify

Declaration

public static void setTimeToMidnight(GregorianCalendar c) 

Method Source Code

//package com.java2s;
/**//from w w  w . j  a  v a  2s .c  o m
 * Copyright (c) 2010 Martin Geisse
 *
 * This file is distributed under the terms of the MIT license.
 */

import java.util.Calendar;

import java.util.GregorianCalendar;

public class Main {
    /**
     * Sets the time fields (24-hour, minute, second, millisecond) of the specified
     * {@link GregorianCalendar} instance to 0 so it subsequently represents midnight
     * of the same day as before.
     * @param c the instance to modify
     */
    public static void setTimeToMidnight(GregorianCalendar c) {
        c.set(Calendar.HOUR_OF_DAY, 0);
        c.set(Calendar.MINUTE, 0);
        c.set(Calendar.SECOND, 0);
        c.set(Calendar.MILLISECOND, 0);
    }
}

Related

  1. setTime(Calendar cal, int h, int m, int s, int ms)
  2. setTime(Calendar cal, String time)
  3. setTime(final Calendar calendat, final String[] test)
  4. setTimeFrom(Calendar c)
  5. setTimeTo0(final Calendar calendar)
  6. setTimeToMinOrMax(Calendar cal, boolean max)
  7. stripTime(final Calendar cal)
  8. stripTimeComponent(Calendar cal)
  9. time2InicioDelDia(Calendar fecha)