java.util.SimpleTimeZone.hasSameRules() Method

Advertisements


Description

The hasSameRules(TimeZone other) method is used to 'true' if this zone has the same rules and offset as another zone.

Declaration

Following is the declaration for java.util.SimpleTimeZone.hasSameRules() method.

public boolean hasSameRules(TimeZone other)

Parameters

  • other--This is the TimeZone object to be compared with

Return Value

The method call returns 'true' if the given zone is a SimpleTimeZone and has the same rules and offset as this one.

Exception

  • NA

Example

The following example shows the usage of java.util.SimpleTimeZone.hasSameRules()

package com.tutorialspoint;

import java.util.*;

public class SimpleTimeZoneDemo {
   public static void main( String args[] ){
      // create two simple time zone object 
      SimpleTimeZone stobj1 = new SimpleTimeZone(820,"US");
      SimpleTimeZone stobj2 = new SimpleTimeZone(820,"GMT");
      
      // check rules for both objects
      boolean samerule=stobj1.hasSameRules(stobj2); 
      
      // checking the value       
      System.out.println("Hash same rule : " + samerule);
   }    
}

Let us compile and run the above program, this will produce the following result.

Hash same rule : true



Advertisements
Advertisements