Home » Java programming language

Java SimpleTimeZone hasSameRules() Method with Example

SimpleTimeZone Class hasSameRules() method: Here, we are going to learn about the hasSameRules() method of SimpleTimeZone Class with its syntax and example.
Submitted by Preeti Jain, on March 12, 2020

SimpleTimeZone Class hasSameRules() method

  • hasSameRules() method is available in java.util package.
  • hasSameRules() method is used to check whether this SimpleTimeZone and the given TimeZone (tz) has the same rules and offset or not.
  • hasSameRules() method is a non-static method, it is accessible with the class object and if we try to access the method with the class name then we will get an error.
  • hasSameRules() method does not throw an exception at the time of checking rules and offset.

Syntax:

    public boolean hasSameRules(TimeZone tz);

Parameter(s):

  • TimeZone tz – represents theTimeZone object to be compared with this SimpleTimeZone.

Return value:

The return type of the method is boolean, it returns true when this object and the given object has same rules and offset otherwise it returns false.

Example:

// Java program to demonstrate the example 
// of boolean hasSameRules(TimeZone tz) method
// of SimpleTimeZone

import java.util.*;

public class HasSameRulesOfSimpleTimeZone {
    public static void main(String args[]) {
        // Instantiates SimpleTimeZone object
        SimpleTimeZone s_tz1 = new SimpleTimeZone(360, "FRANCE");
        SimpleTimeZone s_tz2 = new SimpleTimeZone(760, "JAPAN");

        // By using hasSameRules() method
        // is to check whether the rules of
        // both objects are same or not
        boolean status = s_tz1.hasSameRules(s_tz2);

        // Display status
        System.out.print("s_tz1.hasSameRules(s_tz2): ");
        System.out.println(status);
    }
}

Output

s_tz1.hasSameRules(s_tz2): false






Comments and Discussions

Ad: Are you a blogger? Join our Blogging forum.




Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates


© https://www.includehelp.com some rights reserved.