before()
Java Date before() Method
Last Updated : 17 Mar 2025
The before() method of Java Date class tests whether the date is before the specified date or not.
Syntax:
Parameters
when - a date
Return
It returns a Boolean value. It will return true if this date is before the specified date otherwise false.
Exception
NullPointerException will be thrown if when is null.
Example 1
Output:
Date 'd' is before Date 'd2' : true
Example 2
Output:
Date 'd' is before Date 'd2' : false
Subscribe to Tpoint Tech
We request you to subscribe our newsletter for upcoming updates.