Java Date Time - OffsetTime compareTo(OffsetTime other) example








OffsetTime compareTo(OffsetTime other) compares this OffsetTime to another time.

Syntax

compareTo has the following syntax.

public int compareTo(OffsetTime other)

Example

The following example shows how to use compareTo.

import java.time.OffsetTime;
/* w w w.  j  av a2  s. c  om*/
public class Main {
  public static void main(String[] args) {
    OffsetTime m = OffsetTime.now();

    System.out.println(m.compareTo(OffsetTime.now()));

  }
}

The code above generates the following result.