Java Day From startOfDay(Date date)

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

Description

Returns a new Date with the hours, milliseconds, seconds and minutes set to 0.

License

Open Source License

Parameter

Parameter Description
date Date used in calculating start of day

Return

Start of date

Declaration

public static Date startOfDay(Date date) 

Method Source Code

//package com.java2s;
/*/*ww  w. j  a v  a2  s.  c o m*/
 * $Id: DateUtils.java,v 1.1 2004/08/12 00:24:33 dmouse Exp $
 *
 * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
 * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
 */

import java.util.*;

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

    /**
     * Returns a new Date with the hours, milliseconds, seconds and minutes
     * set to 0.
     *
     * @param date Date used in calculating start of day
     * @return Start of <code>date</code>
     */
    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. isBusinessDay(int dateIntToCheck)
  2. isDefaultWorkingDay(Date date)
  3. isOneDayZeroPoint(Date date)
  4. nextDay(Date date)
  5. nextDay(Date date, int day)
  6. startOfDay(Date datum)