Java Day From getDay(Date date)

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

Description

Gets a date with on the date portion

License

Apache License

Parameter

Parameter Description
date The date

Return

A date with no time information

Declaration

public static Date getDay(Date date) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.util.*;

public class Main {
    /**//from   w w  w  . j a  va 2 s. c  om
     * Gets a date with on the date portion
     * @param date The date
     * @return A date with no time information
     */
    public static Date getDay(Date date) {
        Calendar c = Calendar.getInstance();
        c.setTime(date);
        c.set(Calendar.HOUR_OF_DAY, 0);
        c.set(Calendar.MINUTE, 0);
        c.set(Calendar.SECOND, 0);
        c.set(Calendar.MILLISECOND, 0);
        return c.getTime();
    }

    /**
     * Gets the time portion of the given date
     * @param date The date
     * @return A date with no date information
     */
    public static Date getTime(Date date) {
        Calendar c = Calendar.getInstance();
        c.setTime(date);
        c.set(Calendar.MONTH, 0);
        c.set(Calendar.YEAR, 0);
        c.set(Calendar.DATE, 0);
        return c.getTime();
    }
}

Related

  1. getBeforeDate_(Date date, int day)
  2. getDateByDay(Date date)
  3. getDateByNum(int day)
  4. getDateFromDayNum(int dayNum)
  5. getDateUpDay(Date d)
  6. getDay(Date date)
  7. getDay(Date date, int day)
  8. getDay(String date)
  9. getDay0(Date date)