547 |
{ |
{ |
548 |
int fmt_index = 0; |
int fmt_index = 0; |
549 |
int fmt_max = pattern.length(); |
int fmt_max = pattern.length(); |
550 |
|
Calendar loc_calendar = (Calendar)calendar.clone(); |
551 |
|
|
552 |
calendar.clear(); |
loc_calendar.clear(); |
553 |
boolean saw_timezone = false; |
boolean saw_timezone = false; |
554 |
int quote_start = -1; |
int quote_start = -1; |
555 |
boolean is2DigitYear = false; |
boolean is2DigitYear = false; |
697 |
found_zone = true; |
found_zone = true; |
698 |
saw_timezone = true; |
saw_timezone = true; |
699 |
TimeZone tz = TimeZone.getTimeZone (strings[0]); |
TimeZone tz = TimeZone.getTimeZone (strings[0]); |
700 |
calendar.setTimeZone (tz); |
loc_calendar.setTimeZone (tz); |
701 |
calendar.set (Calendar.ZONE_OFFSET, tz.getRawOffset ()); |
loc_calendar.set (Calendar.ZONE_OFFSET, tz.getRawOffset ()); |
702 |
offset = 0; |
offset = 0; |
703 |
if (k > 2 && tz instanceof SimpleTimeZone) |
if (k > 2 && tz instanceof SimpleTimeZone) |
704 |
{ |
{ |
765 |
} |
} |
766 |
|
|
767 |
// Assign the value and move on. |
// Assign the value and move on. |
768 |
calendar.set(calendar_field, value); |
loc_calendar.set(calendar_field, value); |
769 |
} |
} |
770 |
|
|
771 |
if (is2DigitYear) |
if (is2DigitYear) |
772 |
{ |
{ |
773 |
// Apply the 80-20 heuristic to dermine the full year based on |
// Apply the 80-20 heuristic to dermine the full year based on |
774 |
// defaultCenturyStart. |
// defaultCenturyStart. |
775 |
int year = defaultCentury + calendar.get(Calendar.YEAR); |
int year = defaultCentury + loc_calendar.get(Calendar.YEAR); |
776 |
calendar.set(Calendar.YEAR, year); |
loc_calendar.set(Calendar.YEAR, year); |
777 |
if (calendar.getTime().compareTo(defaultCenturyStart) < 0) |
if (loc_calendar.getTime().compareTo(defaultCenturyStart) < 0) |
778 |
calendar.set(Calendar.YEAR, year + 100); |
loc_calendar.set(Calendar.YEAR, year + 100); |
779 |
} |
} |
780 |
|
|
781 |
try |
try |
784 |
{ |
{ |
785 |
// Use the real rules to determine whether or not this |
// Use the real rules to determine whether or not this |
786 |
// particular time is in daylight savings. |
// particular time is in daylight savings. |
787 |
calendar.clear (Calendar.DST_OFFSET); |
loc_calendar.clear (Calendar.DST_OFFSET); |
788 |
calendar.clear (Calendar.ZONE_OFFSET); |
loc_calendar.clear (Calendar.ZONE_OFFSET); |
789 |
} |
} |
790 |
return calendar.getTime(); |
return loc_calendar.getTime(); |
791 |
} |
} |
792 |
catch (IllegalArgumentException x) |
catch (IllegalArgumentException x) |
793 |
{ |
{ |