Here you can find the source of getDay(Date date)
Parameter | Description |
---|---|
date | The date |
public static Date getDay(Date date)
//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(); } }