Here you can find the source of endOfDay(Date dateInst)
Parameter | Description |
---|---|
dateInst | - instance of Date |
public static Date endOfDay(Date dateInst)
//package com.java2s; /*//from www. j a va 2s . c om Copyright IBM Corp. 2012, 2016 This file is part of Anomaly Detection Engine for Linux Logs (ADE). ADE is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. ADE 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 General Public License for more details. You should have received a copy of the GNU General Public License along with ADE. If not, see <http://www.gnu.org/licenses/>. */ import java.util.Calendar; import java.util.Date; import java.util.GregorianCalendar; public class Main { public static final int LAST_HOUR_OF_DAY = 23; public static final int LAST_MINUTE = 59; public static final int LAST_SECOND = 59; public static final int LAST_MILLISECOND = 999; /** * Method to return an "anti-normalized" version of the input Date * whose time is set to the absolute end of that same day * (last millisecond of last second of last minute of last hour). * * @param dateInst - instance of Date * @return - instance of Date as described */ public static Date endOfDay(Date dateInst) { if (dateInst == null) { throw new IllegalArgumentException(); } final Calendar cal = new GregorianCalendar(); cal.setTime(dateInst); cal.set(Calendar.HOUR_OF_DAY, LAST_HOUR_OF_DAY); cal.set(Calendar.MINUTE, LAST_MINUTE); cal.set(Calendar.SECOND, LAST_SECOND); cal.set(Calendar.MILLISECOND, LAST_MILLISECOND); return cal.getTime(); } }