Java Date Set stripTime(Date d)

Here you can find the source of stripTime(Date d)

Description

set the time portion of a Date to all 0's

License

Open Source License

Declaration

public static Date stripTime(Date d) 

Method Source Code

//package com.java2s;
/*/*from  ww  w.  j  av a2  s . c om*/
 * All GTAS code is Copyright 2016, Unisys Corporation.
 * 
 * Please see LICENSE.txt for details.
 */

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

public class Main {
    /**
     * set the time portion of a Date to all 0's
     */
    public static Date stripTime(Date d) {
        Calendar cal = Calendar.getInstance();
        cal.setTime(d);
        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. setToDayStartTime(Date date)
  2. setToLastDayInMonth(final Date date)
  3. setToMidnight(Date d)
  4. setYear(Date d, int year)
  5. setYear(Date date, int year)
  6. stripTime(Date date)
  7. stripTime(Date date)
  8. stripTime(Date time)
  9. stripTimeFromDate(Date aDate)