The
before() function is a part of Timestamp class of Java SQL.The function returns a boolean value representing whether the Timestamp object occurs before the given Timestamp object.
Function Signature:
public boolean before(Timestamp t)
Syntax:
ts1.before(ts2);
Parameters: The function accepts Timestamp object as parameter which is to be checked.
Return value: The function returns boolean data type representing whether the Timestamp object occurs before the given Timestamp object.
Exception: The function does not throw any exceptions
Below examples illustrate the use of before() function
Example 1: Create two non equal timestamps and check whether the second timestamp occurs before first timestamp or not.
Output:
Second Timestamp occurs before first timestamp
Example 2: Create two equal timestamps and check whether the second timestamp occurs before the first timestamp or not