Here you can find the source of toDayEnds(Date date)
Date
object that represents the ending hour,min,second of a day (i.e., 23:59:59).
Parameter | Description |
---|---|
date | an instantiated date |
date
public static Date toDayEnds(Date date)
//package com.java2s; /*//from ww w .j av a2 s . c o m * gnizr is a trademark of Image Matters LLC in the United States. * * The contents of this file are subject to the Mozilla Public License Version * 1.1 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" basis, * WITHOUT WARRANTY OF ANY KIND, either expressed or implied. See the License * for the specific language governing rights and limitations under the License. * * The Initial Contributor of the Original Code is Image Matters LLC. * Portions created by the Initial Contributor are Copyright (C) 2007 * Image Matters LLC. All Rights Reserved. */ import java.util.Calendar; import java.util.Date; import java.util.GregorianCalendar; public class Main { /** * Returns a <code>Date</code> object that represents the ending * hour,min,second of a day (i.e., 23:59:59). The returned object shares the * same year, month, day values as the input <code>date</code> * * @param date * an instantiated date * @return the ending hour/min/sec of <code>date</code> */ public static Date toDayEnds(Date date) { Calendar cal = GregorianCalendar.getInstance(); cal.setTime(date); cal.set(Calendar.HOUR_OF_DAY, cal.getActualMaximum(Calendar.HOUR_OF_DAY)); cal.set(Calendar.MINUTE, cal.getActualMaximum(Calendar.MINUTE)); cal.set(Calendar.SECOND, cal.getActualMaximum(Calendar.SECOND)); return cal.getTime(); } }