Patch: Another SimpleDateFormat.parse fix
Tom Tromey
tromey@redhat.com
Mon May 14 10:37:00 GMT 2001
I'm checking this in on the trunk.
Jeff and Bryce have convinced me that the calendar fixes are important
enough for the branch. If I find the time I will migrate them over.
If someone else wants to do it, fine...
This patch fixes another bug in SimpleDateFormat.parse(). This bug
occurs when parsing a time to which daylight savings applies but where
the time zone is not specified. I added a Mauve test for this.
I already checked this in to Classpath.
2001-05-14 Tom Tromey <tromey@redhat.com>
* java/text/SimpleDateFormat.java (parse): Clear DST_OFFSET and
ZONE_OFFSET just before computing the time.
Tom
Index: libjava/java/text/SimpleDateFormat.java
===================================================================
RCS file: /cvs/cvsfiles/devo/libjava/java/text/SimpleDateFormat.java,v
retrieving revision 1.11.4.8
diff -u -r1.11.4.8 SimpleDateFormat.java
--- libjava/java/text/SimpleDateFormat.java 2001/05/10 17:54:58 1.11.4.8
+++ libjava/java/text/SimpleDateFormat.java 2001/05/14 17:22:54
@@ -655,8 +655,6 @@
found_zone = true;
TimeZone tz = TimeZone.getTimeZone (strings[0]);
theCalendar.setTimeZone (tz);
- theCalendar.clear (Calendar.DST_OFFSET);
- theCalendar.clear (Calendar.ZONE_OFFSET);
pos.setIndex(index + strings[k].length());
break;
}
@@ -709,6 +707,10 @@
try
{
+ // Clear calendar fields here to force getTime() to correctly
+ // respect DST in the timezone.
+ theCalendar.clear (Calendar.DST_OFFSET);
+ theCalendar.clear (Calendar.ZONE_OFFSET);
return theCalendar.getTime();
}
catch (IllegalArgumentException x)
More information about the Java-patches
mailing list