The hasSameRules() method of TimeZone class in Java is used to check for equality between two TimeZones. The method returns True if the specified TimeZone has same rule and offset value as the other TimeZone.
public boolean hasSameRules(TimeZone TimeZone_2)
Parameters: The method takes one parameter TimeZone_2 of object type which refers to the TimeZone that is needed to be compared with this TimeZone.
Return Value: The method returns boolean True if both the TimeZone share same rule and offset value with only an exception of IDs else False.
Below program illustrates the working of hasSameRules() Method of TimeZone:
The equality holds: true
Attention reader! Don’t stop learning now. Get hold of all the important Java Foundation and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready. To complete your preparation from learning a language to DS Algo and many more, please refer Complete Interview Preparation Course.