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

Java examples for java.lang:Assert

Description

Checks if the given argument is after 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 after = new Date();
        System.out.println(isAfter(value, after));
    }/*from w w w.  ja  v a  2  s .co m*/

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

Related Tutorials