Java Date Now currentDate()

Here you can find the source of currentDate()

Description

current Date

License

Open Source License

Return

the current date without time component

Declaration

public static Date currentDate() 

Method Source Code

//package com.java2s;

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

public class Main {
    /**//from w ww .  jav  a  2s.c  o  m
     * milliseconds in a second.
     */
    public static final long SECOND = 1000;
    /**
     * milliseconds in a minute.
     */
    public static final long MINUTE = SECOND * 60;
    /**
     * milliseconds in a hour.
     */
    public static final long HOUR = MINUTE * 60;

    /**
     * @return the current date without time component
     */
    public static Date currentDate() {
        Calendar calendar = Calendar.getInstance();
        calendar.setTimeInMillis(System.currentTimeMillis());
        calendar.set(Calendar.HOUR, 0);
        calendar.set(Calendar.MINUTE, 0);
        calendar.set(Calendar.SECOND, 0);
        calendar.set(Calendar.MILLISECOND, 0);
        return new Date(calendar.getTimeInMillis());
    }
}

Related

  1. currentAfterDay(Date date)
  2. currentDate()
  3. currentDate()
  4. currentDate()
  5. currentDate()
  6. currentDate()
  7. currentDate()