ICU-5895 Update the previous change. Just save the TimeZone currently used and skip cloning Calendar instance.
X-SVN-Rev: 22688
This commit is contained in:
parent
8697a2c840
commit
20eb5d1d93
@ -562,13 +562,14 @@ public abstract class DateFormat extends UFormat {
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
public Date parse(String text, ParsePosition pos) {
|
||||
Date result = null;
|
||||
int start = pos.getIndex();
|
||||
Calendar workcal = (Calendar)calendar.clone();
|
||||
workcal.clear();
|
||||
parse(text, workcal, pos);
|
||||
TimeZone tzsav = calendar.getTimeZone();
|
||||
calendar.clear();
|
||||
parse(text, calendar, pos);
|
||||
if (pos.getIndex() != start) {
|
||||
try {
|
||||
return workcal.getTime();
|
||||
result = calendar.getTime();
|
||||
} catch (IllegalArgumentException e) {
|
||||
// This occurs if the calendar is non-lenient and there is
|
||||
// an out-of-range field. We don't know which field was
|
||||
@ -577,7 +578,9 @@ public abstract class DateFormat extends UFormat {
|
||||
pos.setErrorIndex(start);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
// Restore TimeZone
|
||||
calendar.setTimeZone(tzsav);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user