SimpleTimeZone equals() method in Java with Examples
Last Updated :
02 Jan, 2019
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:
import java.util.SimpleTimeZone;
public class GFG {
public static void main(String[] args)
{
SimpleTimeZone obj1
= new SimpleTimeZone( 520 , "India" );
SimpleTimeZone obj2
= new SimpleTimeZone( 780 , "India" );
System.out.println( "Result of comparison is : "
+ obj1.equals(obj2));
}
}
|
Output:
Result of comparison is : false
Program 2:
import java.util.SimpleTimeZone;
public class GFG {
public static void main(String[] args)
{
SimpleTimeZone obj1
= new SimpleTimeZone( 520 , "India" );
SimpleTimeZone obj2
= new SimpleTimeZone( 520 , "India" );
System.out.println( "Result of comparison is : "
+ obj1.equals(obj2));
}
}
|
Output:
Result of comparison is : true
Share your thoughts in the comments
Please Login to comment...