Java Calendar Calculate maximizeTime(Calendar cal)

Here you can find the source of maximizeTime(Calendar cal)

Description

Set the time of a calendar to 23:59:59.999

License

Open Source License

Parameter

Parameter Description
cal a parameter

Declaration

public static void maximizeTime(Calendar cal) 

Method Source Code

//package com.java2s;
/*/*from  w  ww . j  a  v  a 2  s . c o  m*/
 * This program 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 2
 * of the License, or (at your option) any later version.
 * 
 * This program 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 this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 */

import java.util.*;

public class Main {
    /**
     * Set the time of a calendar to 23:59:59.999
     *
     * @param cal
     */
    public static void maximizeTime(Calendar cal) {
        // #1753473: thx to Uriah/umlsdl for pointing this out
        cal.set(Calendar.HOUR_OF_DAY, 23);
        cal.set(Calendar.MINUTE, 59);
        cal.set(Calendar.SECOND, 59);
        cal.set(Calendar.MILLISECOND, 999);
    }

    /**
     * Set the time of a date to 23:59:59.999
     */
    public static Date maximizeTime(Date date) {
        Calendar cal = new GregorianCalendar();
        cal.setTime(date);
        maximizeTime(cal);

        return cal.getTime();
    }
}

Related

  1. getTimeStrWithMillisecond(Calendar timeInstance)
  2. isAfterWorkTime(Calendar start)
  3. isInWorkTime(Calendar start)
  4. isSameInstant(Calendar cal1, Calendar cal2)
  5. isSameLocalTime(Calendar cal1, Calendar cal2)
  6. millisToCalendar(long millis)
  7. normalize(final Calendar cal)
  8. normalizedClone(final Calendar cal)
  9. postpone(final Calendar calendar, final int measureUnit, final int amount)