java.util.TimeZone.hasSameRules() 方法
描述
如果此区域与另一个区域具有相同的规则和偏移量,则 hasSameRules(TimeZone other) 方法返回 true。
声明
以下是 java.util.TimeZone.hasSameRules() 方法的声明。
public boolean hasSameRules(TimeZone other)
参数
other − 这是要与之比较的 TimeZone 对象。
返回值
如果其他区域不为 null 并且与此区域相同,则方法调用返回 true,ID 可能存在异常。
异常
NA
示例
下面的例子展示了 java.util.TimeZone.hasSameRules() 的用法。
package com.tutorialspoint;
import java.util.*;
public class TimeZoneDemo {
public static void main( String args[] ) {
// create two time zone objects
TimeZone timezoneone = TimeZone.getDefault();
TimeZone timezonetwo = TimeZone.getDefault();
// comparing two time zones
boolean res = timezoneone.hasSameRules(timezonetwo);
// checking the result
System.out.println("Comparison result:" +res );
}
}
让我们编译并运行上面的程序,这将产生以下结果.
Comparison result:true