Here you can find the source of endOfToday()
public static Date endOfToday()
//package com.java2s; //License from project: Creative Commons License import java.util.Calendar; import java.util.Date; public class Main { protected static Calendar CALENDAR = Calendar.getInstance(); /**//w w w.j a v a2 s .c o m * * @return * @see #endOfDay(Date) */ public static Date endOfToday() { return endOfDay(new Date()); } /** * Get the last hour, minute, second of the date specified * @param date * @return */ public static Date endOfDay(Date date) { Calendar calendar = CALENDAR; synchronized (calendar) { calendar.setTime(date); calendar.set(Calendar.HOUR_OF_DAY, 23); calendar.set(Calendar.MILLISECOND, 999); calendar.set(Calendar.SECOND, 59); calendar.set(Calendar.MINUTE, 59); return calendar.getTime(); } } }