Java Date Time - Period equals(Object obj) example








Period equals(Object obj) checks if this period is equal to another period.

Syntax

equals has the following syntax.

public boolean equals(Object obj)

Example

The following example shows how to use equals.

import java.time.Period;
// w  w w . java 2 s .c  o m
public class Main {
  public static void main(String[] args) {
    Period p = Period.ofDays(12);

    System.out.println(p.equals(Period.ZERO));

  }
}

The code above generates the following result.