.clone()
Anonymous contributor
Anonymous contributor1 total contribution
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 contributorAnonymous contributor1 total contribution
- Anonymous contributor
Looking to contribute?
- 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.