TimeZone clone() Method in Java with Examples Last Updated : 27 Dec, 2018 Comments Improve Suggest changes Like Article Like Report The clone() method of TimeZone class in Java is used to create an identical copy of an existing this TimeZone. Syntax: time_zone.clone() Parameters: The method does not take any parameters. Return Value: The method returns an instance of TimeZone which is the copy of this TimeZone. Below program illustrates the working of clone() Method of TimeZone: Example 1: Java // Java code to illustrate clone() method import java.util.*; public class TimeZoneDemo { public static void main(String args[]) { // Creating an object of TimeZone class. TimeZone time_zone = TimeZone.getDefault(); System.out.println("Original TimeZone: " + time_zone); System.out.println(); // Cloning and displaying the time zone System.out.println("Cloned TimeZone: " + time_zone.clone()); } } Output: Original TimeZone: sun.util.calendar.ZoneInfo[id="Etc/UTC",offset=0,dstSavings=0,useDaylight=false,transitions=0,lastRule=null] Cloned TimeZone: sun.util.calendar.ZoneInfo[id="Etc/UTC",offset=0,dstSavings=0,useDaylight=false,transitions=0,lastRule=null] Example 2: Java // Java code to illustrate clone() method import java.util.*; public class TimeZoneDemo { public static void main(String args[]) { // creating Timezone object whose id is Europe/Berlin TimeZone time_zone = TimeZone.getTimeZone("Europe/Berlin"); System.out.println("Original TimeZone: " + time_zone); System.out.println(); // Cloning and displaying the time zone System.out.println("Cloned TimeZone: " + time_zone.clone()); } } Output: Original TimeZone: sun.util.calendar.ZoneInfo[id="Europe/Berlin",offset=3600000,dstSavings=3600000,useDaylight=true,transitions=143,lastRule=java.util.SimpleTimeZone[id=Europe/Berlin,offset=3600000,dstSavings=3600000,useDaylight=true,startYear=0,startMode=2,startMonth=2,startDay=-1,startDayOfWeek=1,startTime=3600000,startTimeMode=2,endMode=2,endMonth=9,endDay=-1,endDayOfWeek=1,endTime=3600000,endTimeMode=2]] Cloned TimeZone: sun.util.calendar.ZoneInfo[id="Europe/Berlin",offset=3600000,dstSavings=3600000,useDaylight=true,transitions=143,lastRule=java.util.SimpleTimeZone[id=Europe/Berlin,offset=3600000,dstSavings=3600000,useDaylight=true,startYear=0,startMode=2,startMonth=2,startDay=-1,startDayOfWeek=1,startTime=3600000,startTimeMode=2,endMode=2,endMonth=9,endDay=-1,endDayOfWeek=1,endTime=3600000,endTimeMode=2]] Comment More infoAdvertise with us Next Article TimeZone clone() Method in Java with Examples C chinmoy lenka Follow Improve Article Tags : Misc Java Java - util package Java-Functions Java-UUID +1 More Practice Tags : JavaMisc Similar Reads SimpleTimeZone clone() method in Java with Examples The clone() method of SimpleTimeZone class returns a clone of this SimpleTimeZone instance. Syntax: public Object clone() Parameters: The function does not accept any parameter. Return Value: Returns a clone of this instance. Exception: The function does not throws any exception. Program below demon 1 min read TreeMap clone() Method in Java with Examples In Java, clone() method of the TreeMap class is used to return a shallow copy of the mentioned treemap. It just creates a copy of the map. --> java.util Package --> TreeMap Class --> clone() Method Syntax: Tree_Map.clone() Parameters: The method does not take any parameters. Return Type: A 2 min read TimeUnit convert() method in Java with Examples The convert() method of TimeUnit Class is used to convert the given time duration in the given unit to this unit. Since conversion involves from larger to smaller or smaller to larger units, loss of precision and overflow can occur while using this method. Syntax: public long convert(long sourceDura 2 min read Properties clone() method in Java with Examples The Java.util.Properties.clone() method is used to create a shallow copy of this instance with all the elements from this Properties instance. Syntax: public Object clone() Parameters: The method does not take any parameter Return Value: The function returns the cloned Object which is the shallow co 2 min read Stack clone() method in Java with Example The clone() method of Stack class is used to return a shallow copy of this Stack. It just creates a copy of the Stack. The copy will have a reference to a clone of the internal data array but not a reference to the original internal data array. Syntax: Stack.clone()Parameters: The method does not ta 2 min read Like