Here you can find the source of getEndOfDay(Date when)
public static Date getEndOfDay(Date when)
//package com.java2s; //License from project: Apache License import java.util.Calendar; import java.util.Date; public class Main { public static Date getEndOfDay(Date when) { Calendar cal = Calendar.getInstance(); cal.setTime(getStartOfDay(when)); cal.add(Calendar.DATE, 1); cal.add(Calendar.SECOND, -1); return cal.getTime(); }/* ww w . ja v a 2 s .c o m*/ public static Date getStartOfDay(Date when) { Calendar cal = Calendar.getInstance(); cal.setTime(when); cal.set(Calendar.HOUR_OF_DAY, 0); cal.set(Calendar.MINUTE, 0); cal.set(Calendar.SECOND, 0); return cal.getTime(); } }