-
Bug
-
Resolution: Fixed
-
P3
-
1.1.6, 1.2.0
-
1.1.8
-
x86
-
windows_95, windows_nt
-
Verified
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-2020364 | 1.2.0 | Alan Liu | P3 | Resolved | Fixed | 1.2beta4 |
Name: tb29552 Date: 04/30/98
Recent changes designed to fix the behavior of unnamed time zones such as
"GMT+00:30" have introduced a bad side-effect: SimpleDateFormat.subParse()
now throws an exception if you pass just "GMT" as the time zone (the +/-HH:MM
is required). Code to reproduce the problem:
/******** BEGIN TEST CODE ********/
import java.text.ParsePosition;
import java.text.SimpleDateFormat;
import java.util.Date;
public class Crash {
public final static String dateFormat = "MM/dd/yy HH:mm:ss zzz";
public static Date parse(String datestr)
{
SimpleDateFormat fmt = new SimpleDateFormat(dateFormat);
ParsePosition p0 = new ParsePosition(0);
return fmt.parse(datestr, p0);
}
static public void main(String[] args)
{
Date d = parse("01/22/92 04:52:00 GMT");
System.out.println(d.toString());
}
};
/******** END TEST CODE ********/
At the very least, this isn't backward compatible with 1.1.5 and earlier, which
parsed a plain GMT just fine. At worst, it's counter-intuitive (this should work).
A plain GMT is a very common case.
After looking at the bug database, it appears that this may have been
fixed under 4106807 on 1998-03-10 as part of 1.2beta4, but sadly,
the fix didn't make it into JDK 1.1.6.
(Review ID: 29049)
======================================================================
- backported by
-
JDK-2020364 SimpleDateFormat.parse() exception with GMT time zone
-
- Resolved
-
- duplicates
-
JDK-4162770 Out of bounds exception thrown from SimpleDateFormat
-
- Closed
-
- relates to
-
JDK-4266432 Regression test: test/java/text/Format/DateFormatRegression.java failing in ja
-
- Closed
-