📜  Java中的 SimpleTimeZone clone() 方法及示例

📅  最后修改于: 2022-05-13 01:54:58.921000             🧑  作者: Mango

Java中的 SimpleTimeZone clone() 方法及示例

SimpleTimeZone 类clone()方法返回此 SimpleTimeZone 实例的克隆。
句法:

public Object clone()

参数:该函数不接受任何参数。

返回值:返回此实例的克隆。

异常:该函数不抛出任何异常。

下面的程序演示了上述函数:

方案一:

// program to demonstrate the
// function java.util.SimpleTimeZone.clone()
import java.util.SimpleTimeZone;
  
public class GFG {
  
    public static void main(String[] args)
    {
  
        // create simple time zone object
        SimpleTimeZone obj
            = new SimpleTimeZone(520, "India");
  
        // clone the object and print
        System.out.println("Clone object : "
                           + obj.clone());
    }
}
输出:
Clone object :  java.util.SimpleTimeZone
[ 
 id=India,
 offset=520,
 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
]

方案二:

// program to demonstrate the
// function java.util.SimpleTimeZone.clone()
import java.util.SimpleTimeZone;
  
public class GFG {
  
    public static void main(String[] args)
    {
  
        // create simple time zone object
        SimpleTimeZone obj
            = new SimpleTimeZone(120, "India");
  
        // clone the object and print
        System.out.println("Clone object : "
                           + obj.clone());
    }
}
输出:
Clone object :  java.util.SimpleTimeZone
[ 
 id=India,
 offset=120,
 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
]