java - Is it possible to set a Calendar c equal Calendar c2? -
i have:
calendar c = calendar.getinstance(); c.set(calendar.hour_of_day,1); c.set(calendar.minute,23); c.set(calendar.second,22); calendar c2 = calendar.getinstance(); c2 = c ; //
is last statement correct if want set calendar c2 equal calendar c ?
although c2 = c
appear work, that's not want: both variables pointing same calendar instance. result of assignment, changes made c
in c2
well, , vice versa.
you can use clone()
method make copy of calendar
object, this:
calendar c= (calendar)c2.clone();