VOOZH about

URL: https://www.geeksforgeeks.org/java/zoneoffset-equalobject-method-in-java-with-examples/

⇱ ZoneOffset equal(Object) method in Java with Examples - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

ZoneOffset equal(Object) method in Java with Examples

Last Updated : 30 May, 2022

The equals(Object) method of ZoneOffset Class in java.time package is used to check whether the another instance of ZoneOffset passed as the parameter to this ZoneOffset instance, is equal or not. This method returns a boolean value stating the same. Syntax:

public boolean equals(Object object)

Parameters: This method accepts  a parameter object which is to be is equal to this ZoneOffset instance. Return Value: This method returns a boolean value stating whether this ZoneOffset is equal to the instance passed as the parameter. Below examples illustrate the ZoneOffset.equals() method: Example 1: 

Output:
ZoneOffset 1: +05:00
ZoneOffset 2: +05:00
ZoneOffset 1 is equal to ZoneOffset 2: true

Example 2: 

Output:
ZoneOffset 1: +05:00
ZoneOffset 3: +03:00
ZoneOffset 1 is equal to ZoneOffset 3: false

Reference: Oracle Doc

Comment