Java Day Time setToDayStartTime(Date date)

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

Description

set To Day Start Time

License

Open Source License

Declaration

public static Date setToDayStartTime(Date date) 

Method Source Code

//package com.java2s;

import java.text.SimpleDateFormat;
import java.util.*;

public class Main {
    private final static SimpleDateFormat sdfTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

    public static Date setToDayStartTime(Date date) {
        Calendar calendar = Calendar.getInstance();

        calendar.setTimeInMillis(date.getTime());
        calendar.set(Calendar.HOUR_OF_DAY, 0);
        calendar.set(Calendar.MINUTE, 0);
        calendar.set(Calendar.SECOND, 0);
        calendar.set(Calendar.MILLISECOND, 0);

        return calendar.getTime();
    }/*from w ww . ja va 2  s  . c  om*/

    public static String getTime() {
        return sdfTime.format(new Date());
    }
}

Related

  1. beginOfTheDay(Date date)