Quickest way to clone a GregorianCalendar?
Posted
by wds
on Stack Overflow
See other posts from Stack Overflow
or by wds
Published on 2010-03-23T10:36:02Z
Indexed on
2010/03/23
10:43 UTC
Read the original article
Hit count: 199
I'm trying to make a deep copy of an object, including a GregorianCalendar
instance. I'm always wary of using clone()
and it doesn't seem to have been overridden here, so I'm just doing the copy field by field. Ideally, there'd be a copy constructor, which I could use like so:
GregorianCalendar newCalendar = new GregorianCalendar(oldCalendar);
Unfortunately I can't find any such functionality in the API and am stuck trying to figure out which fields I need to get an exact copy. So, to make a copy of one of these calendars, how would you do it? Am I missing some simple shortcut here?
© Stack Overflow or respective owner