Java Date Start getStart(Date date)

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

Description

Returns the given date with the time set to the start of the day.

License

Open Source License

Declaration

public static Date getStart(Date date) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

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

public class Main {
    /** Returns the given date with the time set to the start of the day. */
    public static Date getStart(Date date) {
        return clearTime(date);
    }/*  www .ja  va  2  s.c o m*/

    /** Returns the given date with the time values cleared. */
    public static Date clearTime(Date date) {
        if (date == null) {
            return null;
        }
        Calendar c = Calendar.getInstance();
        c.setTime(date);
        c.set(Calendar.HOUR_OF_DAY, 0);
        c.set(Calendar.MINUTE, 0);
        c.set(Calendar.SECOND, 0);
        c.set(Calendar.MILLISECOND, 0);
        return c.getTime();
    }
}

Related

  1. getStartDate(Date date)
  2. getStartDate(Date date)
  3. getStartDate(Date date)
  4. getStartDate(String date)