SimpleTimeZone equals() method in Java with Examples
The equals() method of SimpleTimeZone class is used to compare the equality of two SimpleTimeZone objects.
Syntax:
public boolean equals(Object obj)
Parameters: The function accepts a single parameter obj which is a SimpleTimeZone object to be compared with.
Return Value: The method returns two values:
- true if the given obj is the same as this SimpleTimeZone object
- false if the given obj is not same as this SimpleTimeZone object
Exception: The function does not throws any exception.
Program below demonstrates the above mentioned function:
Program 1:
// program to demonstrate the // function java.util.date.equals() import java.util.SimpleTimeZone; public class GFG { public static void main(String[] args) { // create first simple time zone object SimpleTimeZone obj1 = new SimpleTimeZone(520, "India"); // create second simple time zone object SimpleTimeZone obj2 = new SimpleTimeZone(780, "India"); // compare two objects and print the result System.out.println("Result of comparison is : " + obj1.equals(obj2)); } } |
Result of comparison is : false
Program 2:
// program to demonstrate the // function java.util.date.equals() import java.util.SimpleTimeZone; public class GFG { public static void main(String[] args) { // create first simple time zone object SimpleTimeZone obj1 = new SimpleTimeZone(520, "India"); // create second simple time zone object SimpleTimeZone obj2 = new SimpleTimeZone(520, "India"); // compare two objects and print the result System.out.println("Result of comparison is : " + obj1.equals(obj2)); } } |
Result of comparison is : true
Recommended Posts:
- SimpleTimeZone setDSTSavings() method in Java with Examples
- SimpleTimeZone toString() method in Java with Examples
- SimpleTimeZone setRawOffset() method in Java with Examples
- SimpleTimeZone hasSameRules() method in Java with Examples
- SimpleTimeZone inDaylightTime() method in Java with Examples
- SimpleTimeZone getDSTSavings() method in Java with Examples
- SimpleTimeZone getOffset() method in Java with Examples
- SimpleTimeZone setEndRule(int, int, int) method in Java with Examples
- SimpleTimeZone hashCode() method in Java with Examples
- SimpleTimeZone getRawOffset() method in Java with Examples
- SimpleTimeZone clone() method in Java with Examples
- SimpleTimeZone setStartRule(int, int, int) method in Java with Examples
- Set equals() method in Java with Examples
- Map equals() method in Java with Examples
- Writer equals() method in Java with Examples
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



