Although it c2 = cwill work, this is not what you want: both variables will point to the same calendar instance. As a result of this assignment, any changes made to cwill also be in c2and vice versa.
You can use the method clone()to create a copy of the object Calendar, for example:
Calendar c= (Calendar)c2.clone();
source
share