java.util.TimeZone.clone() Method

Advertisements


Description

The clone() method is used to create a copy of this TimeZone.

Declaration

Following is the declaration for java.util.TimeZone.clone() method.

public Object clone()

Parameters

  • NA

Return Value

The method call returns a clone of this TimeZone.

Exception

  • NA

Example

The following example shows the usage of java.util.TimeZone.clone()

package com.tutorialspoint;

import java.util.*;

public class TimeZoneDemo {
   public static void main( String args[] ){
       
      // create object of TimeZone class. 
      TimeZone timezoneobj = TimeZone.getDefault(); 
      System.out.println("Original object: " + timezoneobj);
   
      // cloning time zone object
      Object objClone = timezoneobj.clone();      
      System.out.println("Clone object: " + objClone);
   }    
}

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

Original object: 
sun.util.calendar.ZoneInfo[id="Asia/Calcutta",offset=19800000,
dstSavings=0,useDaylight=false,transitions=6,lastRule=null]

Clone object: 
sun.util.calendar.ZoneInfo[id="Asia/Calcutta",offset=19800000,
dstSavings=0,useDaylight=false,transitions=6,lastRule=null]



Advertisements
Advertisements