Java TimeZone clone() Example

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


Syntax is : public Object clone()
This method creates a copy of specified TimeZone.

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

class CloneTimeZone {
    public static void mainString args[] ){
        // Create object of TimeZone class. 
        TimeZone obj = TimeZone.getDefault();
        System.out.println("original object is : \n" + obj);
        // clone() method call that returns clone object of this object.
      Object objClone = obj.clone();
        System.out.println("clone object is : \n" + objClone);
  }
}

Output of the program.
original object is :
sun.util.calendar.ZoneInfo[id="GMT+05:30",offset=19800000,dstSavings=0,useDaylight=false,
transitions=0,lastRule=null]
clone object is :
sun.util.calendar.ZoneInfo[id="GMT+05:30",offset=19800000,dstSavings=0,useDaylight=false,
transitions=0,lastRule=null]

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

HOME | COPYRIGHT | CONTACT US