Here you can find the source of getEndOfDay(Date d)
public static Date getEndOfDay(Date d)
//package com.java2s; //License from project: Open Source License import java.util.*; public class Main { /**// w ww .j av a2 s. com * Returns the last second of the day */ public static Date getEndOfDay(Date d) { return getDateTime(d, 23, 59, 59, 999); } /** * Returns the passed date, at the specified time */ public static Date getDateTime(int year, int mon, int day, int hr, int min, int sec, int ms) { Calendar c = Calendar.getInstance(); c.set(Calendar.YEAR, year); c.set(Calendar.MONTH, mon - 1); c.set(Calendar.DATE, day); c.set(Calendar.HOUR_OF_DAY, hr); c.set(Calendar.MINUTE, min); c.set(Calendar.SECOND, sec); c.set(Calendar.MILLISECOND, ms); return c.getTime(); } /** * Returns the passed date, at midnight */ public static Date getDateTime(int year, int mon, int day) { return getDateTime(year, mon, day, 0, 0, 0, 0); } /** * Returns the passed date, at the specified time */ public static Date getDateTime(Date d, int hour, int minute, int second, int millisecond) { Calendar c = Calendar.getInstance(); c.setTime(d); c.set(Calendar.HOUR_OF_DAY, hour); c.set(Calendar.MINUTE, minute); c.set(Calendar.SECOND, second); c.set(Calendar.MILLISECOND, millisecond); return c.getTime(); } }