Java Day Start startOfDay(Date date)

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

Description

Resettet die Uhrzeit eines Datums.

License

Open Source License

Parameter

Parameter Description
date das Datum.

Return

das neue Datum.

Declaration

public static Date startOfDay(Date date) 

Method Source Code

//package com.java2s;

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

public class Main {
    /**/*w  w  w.j ava2s  .c  o m*/
     * Resettet die Uhrzeit eines Datums.
     * @param date das Datum.
     * @return das neue Datum.
     */
    public static Date startOfDay(Date date) {
        if (date == null)
            return null;

        Calendar cal = Calendar.getInstance();
        cal.setTime(date == null ? new Date() : date);
        cal.set(Calendar.HOUR_OF_DAY, 0);
        cal.set(Calendar.MINUTE, 0);
        cal.set(Calendar.SECOND, 0);
        cal.set(Calendar.MILLISECOND, 0);
        return cal.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)