Java Day End endOfDay(Date date)

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

Description

Get the last hour, minute, second of the date specified

License

Creative Commons License

Parameter

Parameter Description
date a parameter

Declaration

public static Date endOfDay(Date date) 

Method Source Code


//package com.java2s;
//License from project: Creative Commons License 

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

public class Main {
    protected static Calendar CALENDAR = Calendar.getInstance();

    /**//from   w  w  w  .j  a  v a 2  s.c  om
     * Get the last hour, minute, second of the date specified
     * @param date
     * @return
     */
    public static Date endOfDay(Date date) {
        Calendar calendar = CALENDAR;
        synchronized (calendar) {
            calendar.setTime(date);
            calendar.set(Calendar.HOUR_OF_DAY, 23);
            calendar.set(Calendar.MILLISECOND, 999);
            calendar.set(Calendar.SECOND, 59);
            calendar.set(Calendar.MINUTE, 59);
            return calendar.getTime();
        }
    }
}

Related

  1. deltaInDays(Date start, Date end)
  2. deltaMonths(Date start, Date end)
  3. divMonth(Date startDate, Date enDate)
  4. endOfDay(Date aDate)
  5. endOfDay(Date aDate)
  6. endOfDay(Date date)
  7. endOfDay(Date date)
  8. endOfDay(Date date)
  9. endOfDay(Date dateInst)