[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Bug classpath/39789] New: SimpleDateFormat.parse returns incorrect Date
From: |
robert dot dodier at gmail dot com |
Subject: |
[Bug classpath/39789] New: SimpleDateFormat.parse returns incorrect Date |
Date: |
16 Apr 2009 19:41:13 -0000 |
Hello,
I am working with JamVM 1.5.2 + Classpath 0.98 in Linux on an ARM cpu.
I'm working in the US Mountain time zone (GMT minus 6 hours).
I see the following in Jython (which is just a convenient test environment,
I get the same incorrect result when running a Java program by itself).
# jamvm -jar /mnt/mmc/var/lib/jython.jar
Jython 2.2.1 on java1.5.0
>>> import java.text.SimpleDateFormat
>>> java.text.SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ").parse("2009-04-14T20:18:10")
Tue Apr 14 01:18:10 GMT-06:00 2009
Since the string has no timezone indication, the parse method
should fail. Instead it succeeds, and returns a spurious value.
In the same Jython session, when the string has a timezone indication,
>>> java.text.SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ").parse("2009-04-14T20:18:10-0600")
Tue Apr 14 20:18:10 GMT-06:00 2009
which is correct.
I didn't look at the SimpleDateFormat.parse code to see what might be
the problem.
FWIW
Robert Dodier
PS. Here's what I get with Sun's JDK (x86 Linux).
$ java -jar `locate jython.jar`
Jython 2.2.1 on java1.6.0_06
Type "copyright", "credits" or "license" for more information.
>>> import java.text.SimpleDateFormat
>>> java.text.SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ").parse("2009-04-14T20:18:10")
Traceback (innermost last):
File "<console>", line 1, in ?
at java.text.DateFormat.parse(DateFormat.java:337)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
java.text.ParseException: java.text.ParseException: Unparseable date:
"2009-04-14T20:18:10"
>>> java.text.SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ").parse("2009-04-14T20:18:10-0600")
Tue Apr 14 20:18:10 MDT 2009
--
Summary: SimpleDateFormat.parse returns incorrect Date
Product: classpath
Version: 0.98
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: classpath
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: robert dot dodier at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39789
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Bug classpath/39789] New: SimpleDateFormat.parse returns incorrect Date,
robert dot dodier at gmail dot com <=