Java Date Start getStartTimeOfDay(Date date)

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

Description

Get the start time date-time of the given day (ie.

License

Open Source License

Parameter

Parameter Description
date The date-time

Return

The date-time of midnight of the day

Declaration

public static Date getStartTimeOfDay(Date date) 

Method Source Code


//package com.java2s;
//file LICENSE in the root of the DomainHealth distribution.

import static java.util.Calendar.*;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;

public class Main {
    /**/* w  w  w  . j a  v  a  2s  .  c o  m*/
     * Get the start time date-time of the given day (ie. midnight)
     * 
     * @param date The date-time
     * @return The date-time of midnight of the day
     */
    public static Date getStartTimeOfDay(Date date) {
        Calendar currentCalendar = new GregorianCalendar();
        currentCalendar.setTime(date);
        currentCalendar.set(HOUR_OF_DAY, 0);
        currentCalendar.set(MINUTE, 0);
        currentCalendar.set(SECOND, 0);
        return currentCalendar.getTime();
    }
}

Related

  1. getStartOfMonth(Date dt)
  2. getStartOfQuarter(Date dt)
  3. getStartTimeByManDay(Date serviceStartTime)
  4. getStartTimeOfDate(Date date)
  5. getStartTimeOfDay(Date date)
  6. getStrDateToDate(String dateStr)
  7. getStringDate()
  8. getStringDate(byte[] block, int pos)
  9. getStringInDate(String dateString)