Java Day Start startOfDay(Date aDate)

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

Description

Compute day break of the date provided.

License

Apache License

Parameter

Parameter Description
aDate A date with time.

Return

Day break of the date provided. The dawn of a new day.

Declaration

public static Date startOfDay(Date aDate) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

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

public class Main {
    /**// w ww.  ja v  a  2 s .  c  o  m
     * Compute day break of the date provided.
     *
     * @param aDate A date with time.
     * @return Day break of the date provided. The dawn of a new day.
     */
    public static Date startOfDay(Date aDate) {
        Calendar cal = GregorianCalendar.getInstance();
        cal.setTime(aDate);
        cal.set(Calendar.MILLISECOND, 0);
        cal.set(Calendar.SECOND, 0);
        cal.set(Calendar.MINUTE, 0);
        cal.set(Calendar.HOUR_OF_DAY, 0);
        Date dayBreak = cal.getTime();
        return dayBreak;
    }
}

Related

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