Here you can find the source of getEndOfDay(Date date)
Parameter | Description |
---|---|
date | The Date to get the last seconds |
public static Date getEndOfDay(Date date)
//package com.java2s; /*//from w w w . ja v a 2s . c o m * CONFIDENTIAL AND PROPRIETARY SOURCE CODE OF * Institute of Systems Science, National University of Singapore * * Copyright 2012 Team 4(Part-Time), ISS, NUS, Singapore. All rights reserved. * Use of this source code is subjected to the terms of the applicable license * agreement. * * ----------------------------------------------------------------- * REVISION HISTORY * ----------------------------------------------------------------- * DATE AUTHOR REVISION DESCRIPTION * 10 March 2012 Chen Changfeng 0.1 Class creating * * * * * */ import java.util.*; public class Main { /** * Set the time component as the last seconds of the day. * <p> * The Time Component of the date returned will be set to * 23:59:59. * <p> * @param date The Date to get the last seconds * @return The date with the time component set to the last seconds * of the day. */ public static Date getEndOfDay(Date date) { Calendar cal = Calendar.getInstance(); cal.setTime(date); // Clear the time component 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)); cal.set(Calendar.MILLISECOND, cal.getActualMaximum(Calendar.MILLISECOND)); // System.out.println( "cal.toString() = " + cal.toString() ); return cal.getTime(); } }