is Calendar Between two other Calendar - Java java.util

Java examples for java.util:Calendar Calculation

Description

is Calendar Between two other Calendar

Demo Code

/*******************************************************************************
 * Copyright (c) 2004, 2009 Tasktop Technologies and others.
 * 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://from  w ww.  j a  v  a2 s .  c  o m
 *     Tasktop Technologies - initial API and implementation
 *******************************************************************************/
//package com.java2s;
import java.util.Calendar;

public class Main {
    public static void main(String[] argv) throws Exception {
        Calendar time = Calendar.getInstance();
        Calendar start = Calendar.getInstance();
        Calendar end = Calendar.getInstance();
        System.out.println(isBetween(time, start, end));
    }

    public static boolean isBetween(Calendar time, Calendar start,
            Calendar end) {
        return (time.compareTo(start) >= 0 && time.compareTo(end) <= 0);
    }
}

Related Tutorials