Java Data Type How to - Get date begin time


We would like to know how to get date begin time.


import java.util.Calendar;
import java.util.Date;
/*ww w . j av  a  2  s .c  o  m*/
public class Main {

  public static void main(String[] args) {
    System.out.println(getTheBeginingOfDate(new Date()));

  public static Date getTheBeginingOfDate(Date date) {
      Calendar calendar = Calendar.getInstance();
      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();

The code above generates the following result.