Java Day End endOfDay(Date date)

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

Description

Returns the last millisecond of the specified date.

License

Open Source License

Parameter

Parameter Description
date Date to calculate end of day from

Return

Last millisecond of date

Declaration

public static Date endOfDay(Date date) 

Method Source Code

//package com.java2s;
/*//from   w  w  w .  j a v  a 2  s .  c om
 * $Id: DateUtils.java,v 1.1 2004/08/12 00:24:33 dmouse Exp $
 *
 * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
 * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
 */

import java.util.*;

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

    /**
     * Returns the last millisecond of the specified date.
     *
     * @param date Date to calculate end of day from
     * @return Last millisecond of <code>date</code>
     */
    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. endOfDay(Date aDate)
  2. endOfDay(Date aDate)
  3. endOfDay(Date date)
  4. endOfDay(Date date)
  5. endOfDay(Date date)
  6. endOfDay(Date dateInst)
  7. endOfDay(Date dt)
  8. endOfDay(Date inDate, TimeZone timeZone)
  9. endOfDay(Date value)