Name: gsC80088 Date: 02/16/99
Maybe related to: 4106807, 4029994
To reproduce, compile and run this application:
/* SOURCE */
import java.text.*;
import java.util.*;
public class DateParser {
public DateParser() {
DateFormat formatter = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz");
try {
Date myDate = formatter.parse("Fri, 31 Dec 1999 00:00:00 GMT+0100");
System.out.println("Date is: " + myDate);
} catch(ParseException pe2) {
System.out.println("ParseException");
}
}
public static void main (String[] args) {
new DateParser();
}
}
/* END SOURCE */
/* OUTPUT */
Exception in thread "main" java.lang.StringIndexOutOfBoundsException: String ind
ex out of range: 34
at java.lang.String.charAt(Compiled Code)
at java.text.SimpleDateFormat.subParse(Compiled Code)
at java.text.SimpleDateFormat.parse(Compiled Code)
at java.text.DateFormat.parse(Compiled Code)
at DateParser.<init>(Compiled Code)
at DateParser.main(Compiled Code)
/* END OUTPUT */
I think that in the current implementation of SimpleDateFormat, a ParseException would have been thrown
if this bug had not existed.
However, it may be advisable to make the format of the timezone specification user-definable too.
(Review ID: 52227)
======================================================================
- duplicates
-
JDK-4460757 SimpleDateFormat.parse throws StringIndexOutOfBoundsException
- Closed
-
JDK-4460765 Timezone with 1/2 hour offset parsed incorrectly
- Closed
-
JDK-4322313 API:Clarification on custom tz ID in TimeZone and tz formats in SimpleDateFormat
- Resolved