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