Commit 26ec4f47 by Tom Tromey Committed by Tom Tromey

SimpleDateFormat.java (parse): Handle non-dst time zones.

	* java/text/SimpleDateFormat.java (parse): Handle non-dst time
	zones.

From-SVN: r42156
parent df002c7d
2001-05-16 Tom Tromey <tromey@redhat.com>
* java/text/SimpleDateFormat.java (parse): Handle non-dst time
zones.
2001-05-15 Tom Tromey <tromey@redhat.com> 2001-05-15 Tom Tromey <tromey@redhat.com>
* java/util/GregorianCalendar.java (computeTime): Only call * java/util/GregorianCalendar.java (computeTime): Only call
......
...@@ -518,6 +518,7 @@ public class SimpleDateFormat extends DateFormat ...@@ -518,6 +518,7 @@ public class SimpleDateFormat extends DateFormat
// then this.equals() will no longer have the desired result. // then this.equals() will no longer have the desired result.
Calendar theCalendar = (Calendar) calendar.clone (); Calendar theCalendar = (Calendar) calendar.clone ();
theCalendar.clear(); theCalendar.clear();
boolean saw_timezone = false;
int quote_start = -1; int quote_start = -1;
for (; fmt_index < fmt_max; ++fmt_index) for (; fmt_index < fmt_max; ++fmt_index)
{ {
...@@ -635,7 +636,6 @@ public class SimpleDateFormat extends DateFormat ...@@ -635,7 +636,6 @@ public class SimpleDateFormat extends DateFormat
// We need a special case for the timezone, because it // We need a special case for the timezone, because it
// uses a different data structure than the other cases. // uses a different data structure than the other cases.
is_numeric = false; is_numeric = false;
// We don't actually use this; see below.
calendar_field = Calendar.DST_OFFSET; calendar_field = Calendar.DST_OFFSET;
String[][] zoneStrings = formatData.getZoneStrings(); String[][] zoneStrings = formatData.getZoneStrings();
int zoneCount = zoneStrings.length; int zoneCount = zoneStrings.length;
...@@ -653,8 +653,16 @@ public class SimpleDateFormat extends DateFormat ...@@ -653,8 +653,16 @@ public class SimpleDateFormat extends DateFormat
if (k != strings.length) if (k != strings.length)
{ {
found_zone = true; found_zone = true;
saw_timezone = true;
TimeZone tz = TimeZone.getTimeZone (strings[0]); TimeZone tz = TimeZone.getTimeZone (strings[0]);
theCalendar.setTimeZone (tz); theCalendar.setTimeZone (tz);
theCalendar.set (Calendar.ZONE_OFFSET, tz.getRawOffset ());
offset = 0;
if (k > 2 && tz instanceof SimpleTimeZone)
{
SimpleTimeZone stz = (SimpleTimeZone) tz;
offset = stz.getDSTSavings ();
}
pos.setIndex(index + strings[k].length()); pos.setIndex(index + strings[k].length());
break; break;
} }
...@@ -698,19 +706,21 @@ public class SimpleDateFormat extends DateFormat ...@@ -698,19 +706,21 @@ public class SimpleDateFormat extends DateFormat
value = i; value = i;
} }
else else
value = 0; value = offset;
// Assign the value and move on. // Assign the value and move on.
if (calendar_field != Calendar.DST_OFFSET)
theCalendar.set(calendar_field, value); theCalendar.set(calendar_field, value);
} }
try try
{ {
// Clear calendar fields here to force getTime() to correctly if (! saw_timezone)
// respect DST in the timezone. {
// Use the real rules to determine whether or not this
// particular time is in daylight savings.
theCalendar.clear (Calendar.DST_OFFSET); theCalendar.clear (Calendar.DST_OFFSET);
theCalendar.clear (Calendar.ZONE_OFFSET); theCalendar.clear (Calendar.ZONE_OFFSET);
}
return theCalendar.getTime(); return theCalendar.getTime();
} }
catch (IllegalArgumentException x) catch (IllegalArgumentException x)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment