Java Day Start startOfDay(Date date)

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

Description

Get the first hour, minute, second of the date specified

License

Creative Commons License

Parameter

Parameter Description
date a parameter

Declaration

public static Date startOfDay(Date date) 

Method Source Code


//package com.java2s;
//License from project: Creative Commons License 

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

public class Main {
    protected static Calendar CALENDAR = Calendar.getInstance();

    /**/* w  ww.ja  va  2 s  . c  o m*/
     * Get the first hour, minute, second of the date specified
     * @param date
     * @return
     */
    public static Date startOfDay(Date date) {
        Calendar calendar = CALENDAR;
        synchronized (calendar) {
            calendar.setTime(date);
            calendar.set(Calendar.HOUR_OF_DAY, 0);
            calendar.set(Calendar.MILLISECOND, 0);
            calendar.set(Calendar.SECOND, 0);
            calendar.set(Calendar.MINUTE, 0);
            return calendar.getTime();
        }
    }
}

Related

  1. startOfDay(Date aDate)
  2. startOfDay(Date aDate)
  3. startOfDay(Date date)
  4. startOfDay(Date dateInst)
  5. startOfDay(Date inDate, TimeZone timeZone)
  6. startOfDay(Date value)
  7. startOfDay(final Date date)