Java Today toDay()

Here you can find the source of toDay()

Description

to Day

License

Open Source License

Declaration

public static Date toDay() 

Method Source Code

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

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

public class Main {
    public static Date toDay() {
        return removeTime(new Date());
    }//from  w  w  w . j  a v a 2s . co  m

    /**
     * This method remove the time attributes of date object
     *
     * @param date object parameter
     * @return a java.util.Date object without time attributes
     */
    public static Date removeTime(Date date) {
        if (date != null) {
            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();
        }
        return null;
    }
}

Related

  1. today()
  2. today()
  3. today()
  4. today()
  5. today()
  6. today()
  7. today()
  8. today()
  9. today()