Java Calendar Clone() MethodThe clone() method is a method of object class and Object class is super class of all the classes of java. clone() method can be called for the object of calendar class also. Clone method returns the copy of the object. SyntaxParameterThis method does not accept any value. ReturnsThis method returns the copy of this object. ThrowsCloneNotSupportedException. Example 1Test it NowOutput: Actual Calendar Object : Mon Jul 30 09:28:59 PDT 2018 Cloned calendar object : Mon Jul 30 09:28:59 PDT 2018 Example 2Test it NowOutput: Mon Jul 30 09:39:08 PDT 2018 Cloned calendar object: Fri Jul 30 09:39:08 PDT 2027 Example 3Test it NowOutput: Mon Jul 30 09:42:52 PDT 2018 Cloned calendar object : Fri Nov 30 09:42:52 PST 2018 Example 4Test it NowOutput: Mon Jul 30 09:47:25 PDT 2018 Cloned calendar object : Mon Oct 24 15:53:25 PDT 2022
Next TopicJava Calendar Class
|