SimpleTimeZone hasSameRules() method in Java with Examples
Last Updated :
02 Jan, 2019
The hasSameRules() method of SimpleTimeZone class returns ‘true’ if this zone has the same rules and offset as another zone.
Syntax:
public boolean hasSameRules(TimeZone other)
Parameters: The function accepts a single parameter other which is the TimeZone object to be compared with.
Return Value: It returns ‘true’ if the given zone is a SimpleTimeZone and has the same rules and offset as this one.
Exception: The function does not throws any exceptions.
Program below demonstrates the above mentioned function:
Program 1:
import java.util.*;
public class GFG {
public static void main(String[] args)
{
SimpleTimeZone obj1
= new SimpleTimeZone( 720 , "US" );
SimpleTimeZone obj2
= new SimpleTimeZone( 800 , "GMT" );
System.out.println( "Hash same rule = "
+ obj1.hasSameRules(obj2));
}
}
|
Output:
Hash same rule = false
Program 2:
import java.util.*;
public class GFG {
public static void main(String[] args)
{
SimpleTimeZone obj1
= new SimpleTimeZone( 720 , "US" );
SimpleTimeZone obj2
= new SimpleTimeZone( 720 , "GMT" );
System.out.println( "Hash same rule = "
+ obj1.hasSameRules(obj2));
}
}
|
Output:
Hash same rule = true
Share your thoughts in the comments
Please Login to comment...