Here you can find the source of before(final LocalDate d1, final LocalDate d2)
Parameter | Description |
---|---|
d1 | date 1 |
d2 | date 2 |
public static boolean before(final LocalDate d1, final LocalDate d2)
//package com.java2s; /*/*from w ww .ja va 2s . co m*/ * jGnash, a personal finance application * Copyright (C) 2001-2019 Craig Cavanaugh * * 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 3 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, see <http://www.gnu.org/licenses/>. */ import java.time.LocalDate; public class Main { /** * Determines if {@code LocalDate} d1 occurs before {@code LocalDate} d2. The specified dates are * inclusive * * @param d1 date 1 * @param d2 date 2 * @return true if d1 is before d2 or the same date */ public static boolean before(final LocalDate d1, final LocalDate d2) { return before(d1, d2, true); } /** * Determines if {@code LocalDate} d1 occurs before {@code LocalDate} d2. * * @param d1 {@code LocalDate} 1 * @param d2 {@code LocalDate} 2 * @param inclusive {@code true} is comparison is inclusive * @return {@code true} if d1 occurs before d2 */ public static boolean before(final LocalDate d1, final LocalDate d2, final boolean inclusive) { if (inclusive) { return d1.isEqual(d2) || d1.isBefore(d2); } return d1.isBefore(d2); } }