Java Calendar Time time2InicioDelDia(Calendar fecha)

Here you can find the source of time2InicioDelDia(Calendar fecha)

Description

time Inicio Del Dia

License

Open Source License

Declaration

public static void time2InicioDelDia(Calendar fecha) 

Method Source Code


//package com.java2s;
/*/* www  . j a v  a  2s  .co  m*/
 * SAME - Sistema de Gestion de Turnos por Internet
 * SAME is a fork of SAE - Sistema de Agenda Electronica
 * 
 * Copyright (C) 2009  IMM - Intendencia Municipal de Montevideo
 * Copyright (C) 2013, 2014  SAGANT - Codestra S.R.L.
 * Copyright (C) 2013, 2014  Alvaro Rettich <alvaro@sagant.com>
 * Copyright (C) 2013, 2014  Carlos Gutierrez <carlos@sagant.com>
 * Copyright (C) 2013, 2014  Victor Dumas <victor@sagant.com>
 *
 * This file is part of SAME.
    
 * SAME 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 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 Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

import java.util.Calendar;
import java.util.Date;

public class Main {
    public static Date time2InicioDelDia(Date fecha) {

        Calendar cal = Calendar.getInstance();
        cal.setTime(fecha);
        cal.set(Calendar.HOUR_OF_DAY, 0);
        cal.set(Calendar.MINUTE, 0);
        cal.set(Calendar.SECOND, 0);
        cal.set(Calendar.MILLISECOND, 0);

        return cal.getTime();
    }

    public static void time2InicioDelDia(Calendar fecha) {

        fecha.set(Calendar.HOUR_OF_DAY, 0);
        fecha.set(Calendar.MINUTE, 0);
        fecha.set(Calendar.SECOND, 0);
        fecha.set(Calendar.MILLISECOND, 0);

    }
}

Related

  1. setTimeTo0(final Calendar calendar)
  2. setTimeToMidnight(GregorianCalendar c)
  3. setTimeToMinOrMax(Calendar cal, boolean max)
  4. stripTime(final Calendar cal)
  5. stripTimeComponent(Calendar cal)
  6. timestamp17ToCalendar(String timestamp17String)
  7. timestamp2Calendar(long timestamp)
  8. timestampToCalendar(String timestamp)
  9. toDefaultTimeZone(Calendar calendar)