Java TimeZone hasSameRules() Example

TimeZone class hasSameRules() method example. This example shows you how to use hasSameRules() method.


Syntax is : public boolean hasSameRules(TimeZone other)
Method returns true if this zone has the same rule and offset as another zone. That is, if this zone differs only in ID, if at all. Returns false if the other zone is null.

Here is the code.
/**
 * @(#) HasSameRulesTimeZone.java
 * A class representing use of method hasSameRules() of TimeZone
 class in java.util Package.
 * @Version  28-May-2008
 @author   Rose India Team
 */
import java.util.*;

class HasSameRulesTimeZone {
    public static void mainString args[] ){
        // Create object of TimeZone class. 
        TimeZone obj1 = TimeZone.getTimeZone("Europe/Paris");
        TimeZone obj2 = TimeZone.getTimeZone("America/Los_Angeles");
    TimeZone obj3 = TimeZone.getTimeZone("Europe/Paris");

        // hasSameRules() method call.
      boolean bool = obj1.hasSameRules(obj2);
        System.out.println("object obj1 and obj2 has same rules........"+bool);
    bool = obj1.hasSameRules(obj3);
        System.out.println("object obj1 and obj3 has same rules........"+bool);
  }
}

Output of the program.
object obj1 and obj2 has same rules........false
object obj1 and obj3 has same rules........true

Post Comment
Name:
E-mail:
Contact no :
Comments:
  Refresh Image
Verify Image:
 
 
Your Comment's
 
 
 

HOME | COPYRIGHT | CONTACT US