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.
public Object clone()
Parameters: The method does not accept any parameters.
Return Value: The method returns a clone of the object.
Below programs illustrate the use of clone() Method:
Original Date: Thu Dec 05 05:39:04 UTC 1996 Cloned Date: Thu Dec 05 05:39:04 UTC 1996
Original Date: Wed Jan 30 05:39:10 UTC 2019 Cloned Date: Wed Jan 30 05:39:10 UTC 2019
Attention reader! Don’t stop learning now. Get hold of all the important Java Foundation and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready. To complete your preparation from learning a language to DS Algo and many more, please refer Complete Interview Preparation Course.