Clock equals(Object obj) example

Description

Clock equals(Object obj) checks if this clock is equal to another clock.

Syntax

equals has the following syntax.


public boolean equals(Object obj)

Example

The following example shows how to use equals.


import java.time.Clock;
/* w w  w . j av  a2 s  .  c o m*/
public class Main {
  public static void main(String[] args) {
    Clock clock = Clock.systemUTC();
    Clock clock1 = Clock.systemDefaultZone();
    System.out.println(clock.equals(clock1));
  }
}

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