.clone()
Anonymous contributor
Published Jul 31, 2023
Contribute to Docs
The Date.clone()
method returns a copy or duplicate of a specified Date
object.
Syntax
currentDate.clone()
The Date.clone()
method does not take any parameters.
It returns a copy or duplicate of the currentDate
, and the returned value is an Object
, not a Date
.
Example
The following example shows an implementation of Date.clone()
:
import java.util.Date;public class Main {public static void main(String[] args) {Date currentDate = new Date();System.out.println("The original date is " + currentDate);System.out.println("The clone of the date is " + currentDate.clone());}}
The output will be similar to:
The original date is Wed Jul 26 06:47:06 GMT 2023The clone of the date is Wed Jul 26 06:47:06 GMT 2023
All contributors
- Anonymous contributor
Contribute to Docs
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.
Learn Java on Codecademy
- Career path
Computer Science
Looking for an introduction to the theory behind programming? Master Python while learning data structures, algorithms, and more!Includes 6 CoursesWith Professional CertificationBeginner Friendly75 hours - Free course
Learn Java
Learn to code in Java — a robust programming language used to create software, web and mobile apps, and more.Beginner Friendly17 hours