bug report: SimpleDateFormat.parse returns incorrect Date

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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


[Index of Archives]     [Linux Kernel]     [Linux Cryptography]     [Fedora]     [Fedora Directory]     [Red Hat Development]

  Powered by Linux