Java Data Type How to - Get date ending time


We would like to know how to get date ending time.


import java.util.Calendar;
import java.util.Date;
/*  w  w  w.j a  v a2 s .c o m*/
public class Main {

  public static void main(String[] args) {
    System.out.println(getTheEndOfDate(new Date()));

  public static Date getTheEndOfDate(Date date) {
    Calendar calendar = Calendar.getInstance();
    calendar.set(Calendar.HOUR_OF_DAY, 23);
    calendar.set(Calendar.MINUTE, 59);
    calendar.set(Calendar.SECOND, 59);
    calendar.set(Calendar.MILLISECOND, 999);

    return calendar.getTime();

The code above generates the following result.