Android Date Set removeTime(Date date)

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

Description

Remove the time of a date value

License

Open Source License

Parameter

Parameter Description
date Date to remove the time part

Return

A date with its time set to 00:00:00

Declaration

public static Date removeTime(Date date) 

Method Source Code

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

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

public class Main {
    /**//from  w ww  .  j  a v  a 2  s  . c  o  m
     * Remove the time of a date value
     *
     * @param date
     *    Date to remove the time part
     * @return A date with its time set to 00:00:00
     */
    public static Date removeTime(Date date) {
        GregorianCalendar gc = new GregorianCalendar();
        gc.setTime(date);
        gc.set(Calendar.HOUR_OF_DAY, 0);
        gc.set(Calendar.MINUTE, 0);
        gc.set(Calendar.SECOND, 0);
        gc.set(Calendar.MILLISECOND, 0);
        return gc.getTime();
    }
}

Related

  1. toDateTime(Date date, Date time)
  2. offsetDate(Date date, int field, int offset)
  3. changeDate(String argDate)
  4. firstTimeOfDate(Date date)
  5. resetTime(Date date)