Checks if the given argument is after or on a given date. - Java java.lang

Java examples for java.lang:Assert

Description

Checks if the given argument is after or on a given date.

Demo Code


//package com.java2s;

import java.util.Date;

public class Main {
    public static void main(String[] argv) throws Exception {
        Date value = new Date();
        Date afterOrOn = new Date();
        System.out.println(isAfterOrOn(value, afterOrOn));
    }//  w w w . j a  va 2  s  .co m

    /**
     * Checks if the given argument is after or on a given date.
     * @param value The value of the argument to check.
     * @param AfterorEqual The date which must be preceded by value or value
     *        must be on this date.
     * @return True When the value is a date that is after or on the given 
     *         afterOrEqual date; false otherwise.
     */
    public static boolean isAfterOrOn(Date value, Date afterOrOn) {
        return (value == null) || (afterOrOn == null)
                || !(value.after(afterOrOn) || value.equals(afterOrOn));
    }
}

Related Tutorials