ICU-8511 Review fix, setTimeZone should do defensive clone of TimeZone

X-SVN-Rev: 35372
This commit is contained in:
Peter Edberg 2014-03-06 23:28:21 +00:00
parent 9d41d2258a
commit 901f2644d8

View File

@ -892,21 +892,23 @@ public class DateIntervalFormat extends UFormat {
/**
* Set the TimeZone for the calendar used by this DateIntervalFormat object.
* @param zone The new TimeZone to use.
* @param zone The new TimeZone, will be cloned for use by this DateIntervalFormat.
* @draft ICU 53
*/
public void setTimeZone(TimeZone zone)
{
// zone is cloned once for all three usages below:
TimeZone zoneToSet = (TimeZone)zone.clone();
if (fDateFormat != null) {
fDateFormat.setTimeZone(zone);
fDateFormat.setTimeZone(zoneToSet);
}
// fDateFormat has the master calendar for the DateIntervalFormat;
// fFromCalendar and fToCalendar are internal work clones of that calendar.
if (fFromCalendar != null) {
fFromCalendar.setTimeZone(zone);
fFromCalendar.setTimeZone(zoneToSet);
}
if (fToCalendar != null) {
fToCalendar.setTimeZone(zone);
fToCalendar.setTimeZone(zoneToSet);
}
}