Here you can find the source of getDayEnd(Date date)
public static Date getDayEnd(Date date)
//package com.java2s; //License from project: Apache License import java.text.DateFormat; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; public class Main { public final static String longFormat = "yyyyMMddHHmmss"; public static Date getDayEnd(Date date) { DateFormat df = new SimpleDateFormat("yyyyMMdd"); df.setLenient(false);/*w w w.jav a 2 s . c om*/ String dateString = df.format(date); dateString += "235959"; try { return parseDateLongFormat(dateString); } catch (Exception e) { return date; } } public static String format(Date date, String format) { if (date == null) { return null; } return new SimpleDateFormat(format).format(date); } public static Date parseDateLongFormat(String sDate) { DateFormat dateFormat = new SimpleDateFormat(longFormat); Date d = null; if ((sDate != null) && (sDate.length() == longFormat.length())) { try { d = dateFormat.parse(sDate); } catch (ParseException ex) { return null; } } return d; } }