Java Date Convert convertToStartOfDay(Date date)

Here you can find the source of convertToStartOfDay(Date date)

Description

convert To Start Of Day

License

Open Source License

Parameter

Parameter Description
date Any date

Return

The same date but with time equal to 00:00:00

Declaration

public static Date convertToStartOfDay(Date date) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2010 Boeing./*from   w w  w  .ja v a 2s  . c  om*/
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     Boeing - initial API and implementation
 *******************************************************************************/

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

public class Main {
    /**
     * @param date Any date
     * @return The same date but with time equal to 00:00:00
     */
    public static Date convertToStartOfDay(Date date) {
        Calendar cal = Calendar.getInstance();
        cal.setTime(date);
        cal.set(Calendar.HOUR_OF_DAY, 0);
        cal.set(Calendar.MINUTE, 0);
        cal.set(Calendar.SECOND, 0);
        return cal.getTime();
    }
}

Related

  1. convertStringToDate(String string)
  2. convertToClientTime(Date serverDate, Integer clientTimezoneOffset)
  3. convertToDate(String source)
  4. convertToDateStamp(long time)
  5. convertToDateTime(String source)
  6. convertTweetDateToLong(String date)
  7. convertZeroHourDate(Date source)
  8. dateToCal(Date date)
  9. dateToEnglishString(java.util.Date date)