Java Date Before isBefore_day(Date time1, Date time2, int days)

Here you can find the source of isBefore_day(Date time1, Date time2, int days)

Description

time1 < time2 + days

License

Open Source License

Parameter

Parameter Description
time1 a parameter
time2 a parameter
days a parameter

Declaration

public static boolean isBefore_day(Date time1, Date time2, int days) 

Method Source Code

//package com.java2s;
/**/*from www  . ja  va 2s .  c  om*/
*    Copyright (c) 2011-2014, OpenIoT
*   
*    This file is part of OpenIoT.
*
*    OpenIoT is free software: you can redistribute it and/or modify
*    it under the terms of the GNU Lesser General Public License as published by
*    the Free Software Foundation, version 3 of the License.
*
*    OpenIoT 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 Lesser General Public License for more details.
*
*    You should have received a copy of the GNU Lesser General Public License
*    along with OpenIoT.  If not, see <http://www.gnu.org/licenses/>.
*
*     Contact: OpenIoT mailto: info@openiot.eu
*/

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

public class Main {
    /**
     * time1 < time2 + days
     * @param time1
     * @param time2
     * @param days
     * @return
     */
    public static boolean isBefore_day(Date time1, Date time2, int days) {
        if (time2 == null) {
            return false;
        } else if (time1 == null) {
            return true;
        }
        boolean result = false;
        Calendar calendar1 = Calendar.getInstance();
        calendar1.setTime(time1);
        Calendar calendar2 = Calendar.getInstance();
        calendar2.setTime(time2);
        calendar2.add(Calendar.DAY_OF_MONTH, days);
        if (calendar1.before(calendar2)) {
            result = true;
        }
        return result;
    }
}

Related

  1. getSomeDaysBeforeAfter(Date date, int days)
  2. isAtLeastOneDayBefore(Date daybefore, Date dayafter)
  3. isBefore(Date date)
  4. isBefore(Date date1, Date date2)
  5. isBefore2015(Date date)
  6. isBeforeCommonEra(Date date)
  7. isBeforeDate(long time1, long time2)
  8. isBeforeEndOfDate(Date subject, Date predicate)
  9. isDataBeforeData2TruncByDay(Date data1, Date data2)