Here you can find the source of isBefore_day(Date time1, Date time2, int days)
Parameter | Description |
---|---|
time1 | a parameter |
time2 | a parameter |
days | a parameter |
public static boolean isBefore_day(Date time1, Date time2, int days)
//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; } }