Checks if the given argument is before a given date. - Java java.lang

Java examples for java.lang:Assert

Description

Checks if the given argument is before 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 before = new Date();
        System.out.println(isBefore(value, before));
    }//from www. j a v a  2  s  . co  m

    /**
     * Checks if the given argument is before a given date.
     * @param value The value of the argument to check.
     * @param beforeorEqual The date which must be preceded by value.
     * @return True when value precedes the given before date; false otherwise.
     */
    public static boolean isBefore(Date value, Date before) {
        return (value == null) || (before == null) || !value.before(before);
    }
}

Related Tutorials