Java Day End dayEnd(Date dt)

Here you can find the source of dayEnd(Date dt)

Description

Set a Date dt to the end of the day, that is, 11:59:59:999pm return the new Date.

License

Open Source License

Parameter

Parameter Description
dt The given Date

Return

date The day end Date for the given date

Declaration

public static Date dayEnd(Date dt) 

Method Source Code

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

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

public class Main {
    /**/*from w  w  w .java  2  s. c  om*/
     * Set a Date dt to the end of the day, that is, 11:59:59:999pm return the
     * new Date. This could be used for possible scheduling
     * 
     * @param dt
     *            The given Date
     * 
     * @return date The day end Date for the given date
     */
    public static Date dayEnd(Date dt) {
        Calendar cal = Calendar.getInstance();
        cal.setTime(dt);
        cal.set(Calendar.HOUR_OF_DAY, 23);
        cal.set(Calendar.MINUTE, 59);
        cal.set(Calendar.SECOND, 59);
        cal.set(Calendar.MILLISECOND, 999);

        return cal.getTime();
    }
}

Related

  1. countDaysBetween(Date start, Date end)
  2. countMonths(java.util.Date startDate, java.util.Date endDate)
  3. dateBetweens(Date start, Date end)
  4. dateSpan(Date beginDate, Date endDate)
  5. dayBetweenTwoDates(Date beginDate, Date endDate)
  6. dayEnd(final Date date)
  7. daysOfTwoDate(Date beginDate, Date endDate)
  8. dayValue(Date date, boolean startEnd)
  9. deltaInDays(Date start, Date end)