-
Bug
-
Resolution: Fixed
-
P2
-
1.1.6
-
b01
-
generic
-
solaris_2.6
If a date string is parsed which ends in "GMT", then the java code
looks for a time zone offset (eg. GMT+7:00). However, the code calls
charAt() to examine the "+" character without checking the length of the
string, resulting in StringIndexOutOfBoundsException.
---------
Trivial test program - passes in jdk1.1.5, fails in jdk1.1.6 and 1.2beta4.
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
public class SimpleDateFormatTest {
public static void main(String[] args) {
String dateString = "Thu, 30-Jul-1999 11:51:14 GMT";
String format = "EEE', 'dd-MMM-yyyy HH:mm:ss z"; // RFC 822/1123
SimpleDateFormat df = new SimpleDateFormat(format, Locale.US);
try {
Date x = df.parse(dateString);
} catch (Exception e) {
System.err.println("Parse format \"" + format + "\" failed.");
}
}
}