TimeZone 类的 clone() 方法用于创建 TimeZone 类对象的副本。
用法
public Object clone()
返回
它返回 TimeZone 类对象的克隆
例子1
import java.util.*;
public class TimerTaskCloneExample1 {
public static void main( String args[] ) {
// here object is of the class TimerZone.
TimeZone obj = TimeZone.getDefault();
System.out.println("ORIGINAL OBJECT OF TIMERZONE CLASS:" + obj);
// here cloning is done of class TimerZone object.
Object obj1 = obj.clone();
System.out.println("CLONE OBJECT OF TIMERZONE CLASS:" + obj1);
}
}
输出:
ORIGINAL OBJECT OF TIMERZONE CLASS:sun.util.calendar.ZoneInfo[id="Asia/Calcutta",offset=19800000,dstSavings=0, useDaylight=false,transitions=7,lastRule=null] CLONE OBJECT OF TIMERZONE CLASS:sun.util.calendar.ZoneInfo[id="Asia/Calcutta",offset=19800000,dstSavings=0, useDaylight=false,transitions=7,lastRule=null]
例子2
import java.util.SimpleTimeZone;
public class TimerTaskCloneExample2{
public static void main(String[] args) {
// here object is of the class TimerZone.
SimpleTimeZone simpleTimeZone = new SimpleTimeZone(500, "INDIA");
System.out.println("ORIGINAL OBJECT OF TIMERZONE CLASS:" + simpleTimeZone);
// here cloning is done of class TimerZone object.
Object cloneObject = simpleTimeZone.clone();
System.out.println("CLONE OBJECT OF TIMERZONE CLASS:"+ cloneObject);
}
}
输出:
ORIGINAL OBJECT OF TIMERZONE CLASS:java.util.SimpleTimeZone[id=INDIA,offset=500,dstSavings=3600000, useDaylight=false,startYear=0,startMode=0,startMonth=0,startDay=0,startDayOfWeek=0,startTime=0,startTimeMode=0, endMode=0,endMonth=0,endDay=0,endDayOfWeek=0,endTime=0,endTimeMode=0] CLONE OBJECT OF TIMERZONE CLASS:java.util.SimpleTimeZone[id=INDIA,offset=500,dstSavings=3600000, useDaylight=false,startYear=0,startMode=0,startMonth=0,startDay=0,startDayOfWeek=0,startTime=0,startTimeMode=0, endMode=0,endMonth=0,endDay=0,endDayOfWeek=0,endTime=0,endTimeMode=0]
相关用法
- Java TimeZone setDefault()用法及代码示例
- Java TimeZone getDisplayName(boolean, int)用法及代码示例
- Java TimeZone observesDaylightTime()用法及代码示例
- Java TimeZone getDisplayName(Locale locale)用法及代码示例
- Java TimeZone getDefault()用法及代码示例
- Java TimeZone useDaylightTime()用法及代码示例
- Java TimeZone hasSameRules()用法及代码示例
- Java TimeZone setRawOffset()用法及代码示例
- Java TimeZone setID()用法及代码示例
- Java TimeZone getOffset()用法及代码示例
- Java TimeZone getDSTSavings()用法及代码示例
- Java TimeZone getAvailableIDs(int val_offset)用法及代码示例
- Java TimeZone getDisplayName()用法及代码示例
- Java TimeZone clone()用法及代码示例
- Java TimeZone getRawOffset()用法及代码示例
- Java TimeZone getAvailableIDs()用法及代码示例
- Java TimeZone getOffset(int, int, int, int, int, int)用法及代码示例
- Java TimeZone inDaylightTime()用法及代码示例
- Java TimeZone getTimeZone()用法及代码示例
- Java TimeZone getID()用法及代码示例
注:本文由纯净天空筛选整理自 Java TimeZone Clone() Method。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。