Check a Date is Between Two Dates in Java

package nilpointer.net;

import java.text.SimpleDateFormat;
import java.util.Date;

public class Demo {

	public static void main(String[] args) {

		try {
			SimpleDateFormat simpleDateFormat = new SimpleDateFormat("dd/MM/yyyy");

			Date date = simpleDateFormat.parse("22/10/2021");
			Date startDate = simpleDateFormat.parse("20/10/2021");
			Date endDate = simpleDateFormat.parse("26/10/2021");

			if ((date.after(startDate) && (date.before(endDate))) || (date.equals(startDate)) || date.equals(endDate)) {
				System.out.println("Date is between date 1 and date 2");
			} else {
				System.out.println("Date is not between date 1 and date 2");
			}

		} catch (Exception e) {
			System.err.println(e.getMessage());
		}

	}

}
Date is between date 1 and date 2