Here you can find the source of endOfDayInMillis(long date)
Parameter | Description |
---|---|
date | long to calculate end of day from |
date
public static long endOfDayInMillis(long date)
//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(); } } }