Java Date After isEqualOrAfterTomorrow(Date d)

Here you can find the source of isEqualOrAfterTomorrow(Date d)

Description

Returns true if the given date equals or is after tomorrow (ignoring the time)

License

Open Source License

Return

true if the given date is equals or after tomorrow

Declaration

public static boolean isEqualOrAfterTomorrow(Date d) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2008 Ralf Ebert/*w  w w . j a va  2 s  . c  om*/
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 * Ralf Ebert - initial API and implementation
 *******************************************************************************/

import java.util.Calendar;
import java.util.Date;

public class Main {
    /**
     * Returns true if the given date equals or is after tomorrow (ignoring the
     * time)
     * 
     * @return true if the given date is equals or after tomorrow
     */
    public static boolean isEqualOrAfterTomorrow(Date d) {
        return (d != null && !d.before(getTomorrow()));
    }

    /**
     * Returns the date representing tomorrow (by system time) without time
     * 
     * @return Date object representing tomorrow 00:00:00
     */
    public static Date getTomorrow() {
        Calendar c = Calendar.getInstance();
        setZeroTime(c);
        c.add(Calendar.DATE, 1);
        return c.getTime();
    }

    /**
     * Sets hour, minute, second, millisecond set to 0 for the given Calendar
     * object
     * 
     * @param c
     *            Calendar object
     */
    private static void setZeroTime(Calendar c) {
        c.set(Calendar.HOUR_OF_DAY, 0);
        c.set(Calendar.MINUTE, 0);
        c.set(Calendar.SECOND, 0);
        c.set(Calendar.MILLISECOND, 0);
    }
}

Related

  1. isAfter(Date date1, Date date2)
  2. isAfterForDay(Date date, Date ref)
  3. isAfterHour(Date source, int hour)
  4. isAfterToday(Date dag)
  5. isDateAfter(Date date1, Date date2)
  6. isInSameDayOrAfter(Date d1, Date d2)
  7. isNotAfter(Date sDate, Date eDate)
  8. isTimeAfter(Date time1, Date time2)