LocalTime isBefore() method in Java with Examples
The isBefore() method of a LocalTime class is used to check if this LocalTime timeline position is before the LocalTime passed as parameter or not. If this LocalTime timeline position is before the LocalTime passed as a parameter then the method will return true else false. The comparison is based on the time-line position of the instants.
public boolean isBefore(LocalTime other)
Parameters: This method accepts a single parameter other which is the other LocalTime object to compare to. It should not be null.
Return value: This method returns true if this time is before the specified time, else false.
Below programs illustrate the isBefore() method:
LocalTime 1: 19:34:50.630 LocalTime 2: 23:14:00.630 Is LocalTime1 before LocalTime2: true
LocalTime 1: 23:59:11.980 LocalTime 2: 10:24:53.210 Is LocalTime1 before LocalTime2: false
Attention reader! Don’t stop learning now. Get hold of all the important Java Foundation and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready. To complete your preparation from learning a language to DS Algo and many more, please refer Complete Interview Preparation Course.