LocalTime compareTo(LocalTime other) example
Description
LocalTime compareTo(LocalTime other)
compares this LocalTime to
another time.
Syntax
compareTo
has the following syntax.
public int compareTo(LocalTime other)
Example
The following example shows how to use compareTo
.
import java.time.LocalTime;
/* www. j a v a2 s . c o m*/
public class Main {
public static void main(String[] args) {
LocalTime l = LocalTime.now();
System.out.println(l.compareTo(LocalTime.NOON));
}
}
The code above generates the following result.