OffsetTime compareTo(OffsetTime other) example

Description

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;
//from   w  w w. j a  va  2s  .  c  o  m
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.





















Home »
  Java Date Time »
    java.time Reference »




Clock
DayOfWeek
Duration
Instant
LocalDate
LocalDateTime
LocalTime
Month
MonthDay
OffsetDateTime
OffsetTime
Period
Year
YearMonth
ZonedDateTime
ZoneId
ZoneOffset