TimeZone hasSameRules(TimeZone) in Java

hasSameRules(TimeZone): This method is available in java.util.TimeZone class of Java.

Syntax:

boolean java.util.TimeZone.hasSameRules(TimeZone other)

This method takes one argument. This method returns true if this zone has the same rule and offset as another zone.

Parameters: One parameter is required for this method.

other: the TimeZone object to be compared with.

Returns: true if the other zone is not null and is the same as this one, with the possible exception of the ID.

Exceptions: NA

Approach

Java

import java.util.SimpleTimeZone;
import java.util.TimeZone;

public class TimeZonehasSameRules {
    public static void main(String[] args) {

        TimeZone timeZone = new SimpleTimeZone(100, "US");

        TimeZone other = new SimpleTimeZone(100, "US");
        System.out.println(timeZone.hasSameRules(other));
    }
}

Output:

true


No comments:

Post a Comment