Java Day End endOfDayInMillis(long date)

Here you can find the source of endOfDayInMillis(long date)

Description

Returns the last millisecond of the specified date.

License

Open Source License

Parameter

Parameter Description
date long to calculate end of day from

Return

Last millisecond of date

Declaration

public static long endOfDayInMillis(long date) 

Method Source Code

//package com.java2s;
/*/*from w w  w .j a  v  a 2  s.c  o  m*/
 * $Id: DateUtils.java,v 1.4 2005/10/10 18:02:45 rbair Exp $
 *
 * Copyright 2004 Sun Microsystems, Inc., 4150 Network Circle,
 * Santa Clara, California 95054, U.S.A. All rights reserved.
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 * 
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 */

import java.util.Calendar;

public class Main {
    /**
     * Returns the last millisecond of the specified date.
     *
     * @param date long to calculate end of day from
     * @return Last millisecond of <code>date</code>
     */
    public static long endOfDayInMillis(long date) {
        Calendar calendar = Calendar.getInstance();
        synchronized (calendar) {
            calendar.setTimeInMillis(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.getTimeInMillis();
        }
    }
}

Related

  1. endOfDay(Date inDate, TimeZone timeZone)
  2. endOfDay(Date value)
  3. endOfDay(final Date date)
  4. endOfDay(final Date date)
  5. endOfDayDate(Date date)
  6. endOfTheMonth(java.util.Date date, Locale locale)
  7. endOfYear(Date referenceDate, TimeZone timeZone)
  8. fillBetweenDays(Date from, Date to)
  9. getAgeInDays(Date startDate, Date endDate)