DateFormat clone() method in Java with Examples Last Updated : 27 Mar, 2019 Summarize Comments Improve Suggest changes Share Like Article Like Report The clone() Method of DateFormat class is used to create a copy of this DateFormat. It creates another copy of this DateFormat. Syntax: public Object clone() Parameters: The method does not take any parameters. Return Value: The method returns a copy of the DateFormat. Below programs illustrate the working of clone() Method of DateFormat: Example 1: Java // Java to illustrate clone() method import java.text.*; import java.util.*; public class DateFormat_Demo { public static void main(String[] args) { // Initializing DateFormat DateFormat DFormat = DateFormat.getDateTimeInstance(); // Displaying the formats Date date = new Date(); String str_Date1 = DFormat.format(date); System.out.println("The Original: " + (str_Date1)); // Using clone() System.out.println("Is the clone equal? " + DFormat.clone() .equals(DFormat)); } } Output: The Original: Mar 27, 2019 10:09:48 AM Is the clone equal? true Example 2: Java // Java to illustrate clone() method import java.text.*; import java.util.*; public class DateFormat_Demo { public static void main(String[] args) { // Initializing DateFormat DateFormat DFormat = new SimpleDateFormat("MM/dd/yyyy"); // Displaying the formats Date date = new Date(); String str_Date1 = DFormat.format(date); System.out.println("The Original: " + (str_Date1)); // Using clone() System.out.println("Is the clone equal? " + DFormat.clone() .equals(DFormat)); } } Output: The Original: 03/27/2019 Is the clone equal? true Reference: https://docs.oracle.com/javase/7/docs/api/java/text/DateFormat.html#clone() Comment More infoAdvertise with us Next Article DateFormat clone() method in Java with Examples C chinmoy lenka Follow Improve Article Tags : Misc Java Java - util package Java-Functions Java-DateFormat +1 More Practice Tags : JavaMisc Similar Reads Date clone() method in Java with Examples The clone() method of Date class in Java returns the duplicate of the passed Date object. This duplicate is just a shallow copy of the given Date object.Syntax: public Object clone() Parameters: The method does not accept any parameters.Return Value: The method returns a clone of the object.Below pr 2 min read DecimalFormatSymbols clone() method in Java with Examples The clone() method of java.text.DecimalFormatSymbols class in Java is used to clone this DecimalFormatSymbols. It means that this method will create another instance of DecimalFormatSymbols with all the properties the same as this DecimalFormatSymbols and return it. Syntax: public Object clone() Par 1 min read DateFormat format() Method in Java with Examples DateFormat class present inside java.text package is an abstract class that is used to format and parse dates for any locale. It allows us to format date to text and parse text to date. DateFormat class provides many functionalities to obtain, format, parse default date/time. DateFormat class extend 2 min read DateFormat equals() Method in Java with Examples The equals() Method of the DateFormat class is used to compare two DateFormat objects. The method returns True if this DateFormat is equal to the passed object else returns False. Syntax: public boolean equals(Object obj) Parameters: The method takes one parameter obj of Object type and refers to th 2 min read Java DateFormat getInstance() Method with Examples The getInstance() method of DateFormat class will return the date and time formatter with the default formatting style for the default locale. Syntax: public static final DateFormat getInstance() Parameter: This method doesn't require any parameters. Return value: This method will return the date fo 2 min read Like