Java Day End getEndOfTheDate(Date date)

Here you can find the source of getEndOfTheDate(Date date)

Description

Precondition: date argument is not null.

License

Open Source License

Parameter

Parameter Description
date the Date object

Return

a Date object set to end of the date

Declaration

public static Date getEndOfTheDate(Date date) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.util.Calendar;
import java.util.Date;

public class Main {
    /**//w w w.  j  av  a 2  s . c  om
     * Precondition: date argument is not null.
     * Returns a Date object using date with time set to end of day.
     * @param date the Date object
     * @return a Date object set to end of the date
     */
    public static Date getEndOfTheDate(Date date) {
        assert date != null;
        Calendar c = Calendar.getInstance();
        c.setTime(date);
        c.set(Calendar.HOUR_OF_DAY, 23);
        c.set(Calendar.MINUTE, 59);
        c.set(Calendar.SECOND, 59);
        c.set(Calendar.MILLISECOND, 999);
        return c.getTime();
    }
}

Related

  1. getEndOfDay(Date day)
  2. getEndOfDay(Date when)
  3. getEndOfDay(final Date date, final TimeZone timeZone)
  4. getEndOfDay(Long date)
  5. getEndOfHour(Date day)
  6. getEndOfYear(Date dt)
  7. getEndQuaterly(Date startDate)
  8. getEndSixMonthly(Date startDate)
  9. getEndTimeOfDay(Date date)