Discussion:
Java 7 breaks SimpleDateFormatter?
Ron Reynolds
2013-11-12 02:31:04 UTC
Permalink
I can't believe this so if anyone can point out the error in my ways please do so.

$ cat Test.java
import java.util.Date;
import java.text.SimpleDateFormat;
import java.util.TimeZone;

public class Test {
    public static void main(String[] args) throws Exception {
        SimpleDateFormat formatter = new SimpleDateFormat("MM/dd/yyyy'-'hh");
        formatter.setTimeZone(TimeZone.getTimeZone("GMT"));
        formatter.setLenient(false);

        Date d1 = formatter.parse("10/10/2013-00");
        System.out.println(d1);
    }
}

$ /usr/java/jdk1.6.0_24/bin/javac Test.java

$ /usr/java/jdk1.6.0_24/bin/java -cp . Test
Wed Oct 09 17:00:00 PDT 2013

$ /usr/java/jdk1.7.0_45/bin/java -cp . Test
Exception in thread "main" java.text.ParseException: Unparseable date: "10/10/2013-00"
        at java.text.DateFormat.parse(DateFormat.java:357)
        at Test.main(Test.java:11)

!?!?!?
still hunting for my own hints/answers but in case someone already hit this please share. :)
Laird Nelson
2013-11-12 02:40:59 UTC
Permalink
Forgot to quote the slashes? Just a guess; didn't try it.

Best,
Laird
Post by Ron Reynolds
I can't believe this so if anyone can point out the error in my ways please do so.
$ cat Test.java
import java.util.Date;
import java.text.SimpleDateFormat;
import java.util.TimeZone;
public class Test {
public static void main(String[] args) throws Exception {
SimpleDateFormat formatter = new
SimpleDateFormat("MM/dd/yyyy'-'hh");
formatter.setTimeZone(TimeZone.getTimeZone("GMT"));
formatter.setLenient(false);
Date d1 = formatter.parse("10/10/2013-00");
System.out.println(d1);
}
}
$ /usr/java/jdk1.6.0_24/bin/javac Test.java
$ /usr/java/jdk1.6.0_24/bin/java -cp . Test
Wed Oct 09 17:00:00 PDT 2013
$ /usr/java/jdk1.7.0_45/bin/java -cp . Test
Exception in thread "main" java.text.ParseException: Unparseable date: "10/10/2013-00"
at java.text.DateFormat.parse(DateFormat.java:357)
at Test.main(Test.java:11)
!?!?!?
still hunting for my own hints/answers but in case someone already hit
this please share. :)
--
http://about.me/lairdnelson
Ron Reynolds
2013-11-12 02:41:06 UTC
Permalink
it appears they changed the hour rules.  changing 'hh' to 'HH' fixed it (also they seem to have dropped the need to escape the '-').  weird.



On Monday, November 11, 2013 6:31 PM, Ron Reynolds <tequilaron-***@public.gmane.org> wrote:

 
I can't believe this so if anyone can point out the error in my ways please do so.

$ cat Test.java
import java.util.Date;
import java.text.SimpleDateFormat;
import java.util.TimeZone;

public class Test {
    public static void main(String[] args) throws Exception {
        SimpleDateFormat formatter = new SimpleDateFormat("MM/dd/yyyy'-'hh");
        formatter.setTimeZone(TimeZone.getTimeZone("GMT"));
        formatter.setLenient(false);

        Date d1 = formatter.parse("10/10/2013-00");
        System.out.println(d1);
    }
}

$ /usr/java/jdk1.6.0_24/bin/javac Test.java

$ /usr/java/jdk1.6.0_24/bin/java -cp . Test
Wed Oct 09 17:00:00 PDT 2013

$ /usr/java/jdk1.7.0_45/bin/java -cp . Test
Exception in thread "main" java.text.ParseException: Unparseable date: "10/10/2013-00"
        at java.text.DateFormat.parse(DateFormat.java:357)
        at Test.main(Test.java:11)

!?!?!?
still hunting for my own hints/answers but in case someone already hit this please share. :)
Daniel Kirkdorffer
2013-11-12 03:09:10 UTC
Permalink
Doesn't appear so. That would be really bad.

They've added some letters, but none of the ones available in Java 6 have
changed.

Dan


-----Original Message-----
From: seajug-***@public.gmane.org [mailto:seajug-***@public.gmane.org] On Behalf Of
Ron Reynolds
Sent: Monday, November 11, 2013 6:41 PM
To: seajug-***@public.gmane.org
Subject: Re: [seajug] Java 7 breaks SimpleDateFormatter?






it appears they changed the hour rules. changing 'hh' to 'HH' fixed it
(also they seem to have dropped the need to escape the '-'). weird.


On Monday, November 11, 2013 6:31 PM, Ron Reynolds <tequilaron-***@public.gmane.org>
wrote:


I can't believe this so if anyone can point out the error in my ways please
do so.

$ cat Test.java
import java.util.Date;
import java.text.SimpleDateFormat;
import java.util.TimeZone;


public class Test {
public static void main(String[] args) throws Exception {
SimpleDateFormat formatter = new
SimpleDateFormat("MM/dd/yyyy'-'hh");
formatter.setTimeZone(TimeZone.getTimeZone("GMT"));
formatter.setLenient(false);


Date d1 = formatter.parse("10/10/2013-00");
System.out.println(d1);
}
}

$ /usr/java/jdk1.6.0_24/bin/javac Test.java

$ /usr/java/jdk1.6.0_24/bin/java -cp . Test
Wed Oct 09 17:00:00 PDT 2013

$ /usr/java/jdk1.7.0_45/bin/java -cp . Test
Exception in thread "main" java.text.ParseException: Unparseable date:
"10/10/2013-00"
at java.text.DateFormat.parse(DateFormat.java:357)
at Test.main(Test.java:11)

!?!?!?
still hunting for my own hints/answers but in case someone already hit this
please share. :)
Ron Reynolds
2013-11-12 03:22:59 UTC
Permalink
i'm certain (as shown below) that the lower-case h worked for 00-23 hours and now H seems to be required so more accurate to say they tightened up the rules?


________________________________
From: Daniel Kirkdorffer <dankirkd-***@public.gmane.org>
To: seajug-***@public.gmane.org
Sent: Monday, November 11, 2013 7:09 PM
Subject: RE: [seajug] Java 7 breaks SimpleDateFormatter?



 
Doesn't appear so.  That would be really
bad.
 
They've added some letters, but none of the ones
available in Java 6 have changed.
 
Dan
 
-----Original Message-----
Post by Daniel Kirkdorffer
Sent: Monday, November 11, 2013 6:41 PM
Subject: Re: [seajug] Java 7 breaks SimpleDateFormatter?
 
it appears they changed the hour rules.  changing 'hh' to 'HH' fixed it (also they seem to have dropped the need to escape the '-').  weird.
 
I can't believe this so if anyone can point out the error in my ways please do so.
$ cat Test.java
import java.util.Date;
import java.text.SimpleDateFormat;
import java.util.TimeZone;
public class Test {
    public static void main(String[] args) throws Exception {
        SimpleDateFormat formatter = new SimpleDateFormat("MM/dd/yyyy'-'hh");
        formatter.setTimeZone(TimeZone.getTimeZone("GMT"));
        formatter.setLenient(false);
        Date d1 = formatter.parse("10/10/2013-00");
        System.out.println(d1);
    }
}
$ /usr/java/jdk1.6.0_24/bin/javac Test.java
$ /usr/java/jdk1.6.0_24/bin/java -cp . Test
Wed Oct 09 17:00:00 PDT 2013
$ /usr/java/jdk1.7.0_45/bin/java -cp . Test
Exception in thread "main" java.text.ParseException: Unparseable date: "10/10/2013-00"
        at java.text.DateFormat.parse(DateFormat.java:357)
        at Test.main(Test.java:11)
!?!?!?
still hunting for my own hints/answers but in case someone already hit this please share. :)
Daniel Kirkdorffer
2013-11-12 03:29:59 UTC
Permalink
Java 7:

H Hour in day (0-23) Number
<http://docs.oracle.com/javase/7/docs/api/java/text/SimpleDateFormat.html#nu
mber> 0
k Hour in day (1-24) Number
<http://docs.oracle.com/javase/7/docs/api/java/text/SimpleDateFormat.html#nu
mber> 24
K Hour in am/pm (0-11) Number
<http://docs.oracle.com/javase/7/docs/api/java/text/SimpleDateFormat.html#nu
mber> 0
h Hour in am/pm (1-12) Number
<http://docs.oracle.com/javase/7/docs/api/java/text/SimpleDateFormat.html#nu
mber> 12

Java 6:

H Hour in day (0-23) Number
<http://jcs.mobile-utopia.com/jcs/78569_SimpleDateFormat.html2#number>
0
k Hour in day (1-24) Number
<http://jcs.mobile-utopia.com/jcs/78569_SimpleDateFormat.html2#number>
24
K Hour in am/pm (0-11) Number
<http://jcs.mobile-utopia.com/jcs/78569_SimpleDateFormat.html2#number>
0
h Hour in am/pm (1-12) Number
<http://jcs.mobile-utopia.com/jcs/78569_SimpleDateFormat.html2#number>
12

I see no change in the Javadoc.


-----Original Message-----
From: seajug-***@public.gmane.org [mailto:seajug-***@public.gmane.org] On Behalf Of
Ron Reynolds
Sent: Monday, November 11, 2013 7:23 PM
To: seajug-***@public.gmane.org
Subject: Re: [seajug] Java 7 breaks SimpleDateFormatter?






i'm certain (as shown below) that the lower-case h worked for 00-23 hours
and now H seems to be required so more accurate to say they tightened up the
rules?

_____

From: Daniel Kirkdorffer <dankirkd-***@public.gmane.org>
To: seajug-***@public.gmane.org
Sent: Monday, November 11, 2013 7:09 PM
Subject: RE: [seajug] Java 7 breaks SimpleDateFormatter?



Doesn't appear so. That would be really bad.

They've added some letters, but none of the ones available in Java 6 have
changed.

Dan


-----Original Message-----
From: seajug-***@public.gmane.org [mailto:seajug-***@public.gmane.org] On Behalf Of
Ron Reynolds
Sent: Monday, November 11, 2013 6:41 PM
To: seajug-***@public.gmane.org
Subject: Re: [seajug] Java 7 breaks SimpleDateFormatter?



it appears they changed the hour rules. changing 'hh' to 'HH' fixed it
(also they seem to have dropped the need to escape the '-'). weird.


On Monday, November 11, 2013 6:31 PM, Ron Reynolds <tequilaron-***@public.gmane.org>
wrote:


I can't believe this so if anyone can point out the error in my ways please
do so.

$ cat Test.java
import java.util.Date;
import java.text.SimpleDateFormat;
import java.util.TimeZone;


public class Test {
public static void main(String[] args) throws Exception {
SimpleDateFormat formatter = new
SimpleDateFormat("MM/dd/yyyy'-'hh");
formatter.setTimeZone(TimeZone.getTimeZone("GMT"));
formatter.setLenient(false);


Date d1 = formatter.parse("10/10/2013-00");
System.out.println(d1);
}
}

$ /usr/java/jdk1.6.0_24/bin/javac Test.java

$ /usr/java/jdk1.6.0_24/bin/java -cp . Test
Wed Oct 09 17:00:00 PDT 2013

$ /usr/java/jdk1.7.0_45/bin/java -cp . Test
Exception in thread "main" java.text.ParseException: Unparseable date:
"10/10/2013-00"
at java.text.DateFormat.parse(DateFormat.java:357)
at Test.main(Test.java:11)

!?!?!?
still hunting for my own hints/answers but in case someone already hit this
please share. :)
Robert Hall
2013-11-12 03:35:41 UTC
Permalink
I wonder if the issue is not with the 'hh' but the '-'...I've not seen a
date formatted like "10/10/2013-00". But Java 6 parsed it.

R
H Hour in day (0-23) Number<http://docs.oracle.com/javase/7/docs/api/java/text/SimpleDateFormat.html#number>
0 k Hour in day (1-24) Number<http://docs.oracle.com/javase/7/docs/api/java/text/SimpleDateFormat.html#number>
24 K Hour in am/pm (0-11) Number<http://docs.oracle.com/javase/7/docs/api/java/text/SimpleDateFormat.html#number>
0 h Hour in am/pm (1-12) Number<http://docs.oracle.com/javase/7/docs/api/java/text/SimpleDateFormat.html#number>
12
H Hour in day (0-23) Number<http://jcs.mobile-utopia.com/jcs/78569_SimpleDateFormat.html2#number>
0 k Hour in day (1-24) Number<http://jcs.mobile-utopia.com/jcs/78569_SimpleDateFormat.html2#number>
24 K Hour in am/pm (0-11) Number<http://jcs.mobile-utopia.com/jcs/78569_SimpleDateFormat.html2#number>
0 h Hour in am/pm (1-12) Number<http://jcs.mobile-utopia.com/jcs/78569_SimpleDateFormat.html2#number>
12
I see no change in the Javadoc.
-----Original Message-----
Of *Ron Reynolds
*Sent:* Monday, November 11, 2013 7:23 PM
*Subject:* Re: [seajug] Java 7 breaks SimpleDateFormatter?
i'm certain (as shown below) that the lower-case h worked for 00-23
hours and now H seems to be required so more accurate to say they tightened
up the rules?
------------------------------
*Sent:* Monday, November 11, 2013 7:09 PM
*Subject:* RE: [seajug] Java 7 breaks SimpleDateFormatter?
Doesn't appear so. That would be really bad.
They've added some letters, but none of the ones available in Java 6 have
changed.
Dan
-----Original Message-----
Of *Ron Reynolds
*Sent:* Monday, November 11, 2013 6:41 PM
*Subject:* Re: [seajug] Java 7 breaks SimpleDateFormatter?
it appears they changed the hour rules. changing 'hh' to 'HH' fixed it
(also they seem to have dropped the need to escape the '-'). weird.
I can't believe this so if anyone can point out the error in my ways
please do so.
$ cat Test.java
import java.util.Date;
import java.text.SimpleDateFormat;
import java.util.TimeZone;
public class Test {
public static void main(String[] args) throws Exception {
SimpleDateFormat formatter = new
SimpleDateFormat("MM/dd/yyyy'-'hh");
formatter.setTimeZone(TimeZone.getTimeZone("GMT"));
formatter.setLenient(false);
Date d1 = formatter.parse("10/10/2013-00");
System.out.println(d1);
}
}
$ /usr/java/jdk1.6.0_24/bin/javac Test.java
$ /usr/java/jdk1.6.0_24/bin/java -cp . Test
Wed Oct 09 17:00:00 PDT 2013
$ /usr/java/jdk1.7.0_45/bin/java -cp . Test
"10/10/2013-00"
at java.text.DateFormat.parse(DateFormat.java:357)
at Test.main(Test.java:11)
!?!?!?
still hunting for my own hints/answers but in case someone already hit
this please share. :)
--
Robert Hall
robertwadehall-***@public.gmane.org
Daniel Kirkdorffer
2013-11-12 03:59:57 UTC
Permalink
No. That's not the issue.

It appears that with Java 6 hh parsed zeros, but now it correctly doesn't.

These all parsed in Java 6:

formatter.parse("10/10/2013-0")
formatter.parse("10/10/2013-00")
formatter.parse("10/10/2013-1")
formatter.parse("10/10/2013-12")

but this doesn't:

formatter.parse("10/10/2013-13")

In Java 7 the first two of those don't parse.


-----Original Message-----
From: seajug-***@public.gmane.org [mailto:seajug-***@public.gmane.org] On Behalf Of
Robert Hall
Sent: Monday, November 11, 2013 7:36 PM
To: seajug-***@public.gmane.org
Subject: Re: [seajug] Java 7 breaks SimpleDateFormatter?






I wonder if the issue is not with the 'hh' but the '-'...I've not seen a
date formatted like "10/10/2013-00". But Java 6 parsed it.


R



On 11 November 2013 20:29, Daniel Kirkdorffer <dankirkd-***@public.gmane.org> wrote:







Java 7:


H Hour in day (0-23) Number
<http://docs.oracle.com/javase/7/docs/api/java/text/SimpleDateFormat.html#nu
mber> 0
k Hour in day (1-24) Number
<http://docs.oracle.com/javase/7/docs/api/java/text/SimpleDateFormat.html#nu
mber> 24
K Hour in am/pm (0-11) Number
<http://docs.oracle.com/javase/7/docs/api/java/text/SimpleDateFormat.html#nu
mber> 0
h Hour in am/pm (1-12) Number
<http://docs.oracle.com/javase/7/docs/api/java/text/SimpleDateFormat.html#nu
mber> 12

Java 6:


H Hour in day (0-23) Number
<http://jcs.mobile-utopia.com/jcs/78569_SimpleDateFormat.html2#number>
0
k Hour in day (1-24) Number
<http://jcs.mobile-utopia.com/jcs/78569_SimpleDateFormat.html2#number>
24
K Hour in am/pm (0-11) Number
<http://jcs.mobile-utopia.com/jcs/78569_SimpleDateFormat.html2#number>
0
h Hour in am/pm (1-12) Number
<http://jcs.mobile-utopia.com/jcs/78569_SimpleDateFormat.html2#number>
12

I see no change in the Javadoc.



-----Original Message-----
From: seajug-***@public.gmane.org [mailto:seajug-***@public.gmane.org] On Behalf Of
Ron Reynolds

Sent: Monday, November 11, 2013 7:23 PM
To: seajug-***@public.gmane.org
Subject: Re: [seajug] Java 7 breaks SimpleDateFormatter?






i'm certain (as shown below) that the lower-case h worked for 00-23 hours
and now H seems to be required so more accurate to say they tightened up the
rules?

_____

From: Daniel Kirkdorffer <dankirkd-***@public.gmane.org>
To: seajug-***@public.gmane.org
Sent: Monday, November 11, 2013 7:09 PM
Subject: RE: [seajug] Java 7 breaks SimpleDateFormatter?



Doesn't appear so. That would be really bad.

They've added some letters, but none of the ones available in Java 6 have
changed.

Dan


-----Original Message-----
From: seajug-***@public.gmane.org [mailto:seajug-***@public.gmane.org] On Behalf Of
Ron Reynolds
Sent: Monday, November 11, 2013 6:41 PM
To: seajug-***@public.gmane.org
Subject: Re: [seajug] Java 7 breaks SimpleDateFormatter?



it appears they changed the hour rules. changing 'hh' to 'HH' fixed it
(also they seem to have dropped the need to escape the '-'). weird.


On Monday, November 11, 2013 6:31 PM, Ron Reynolds <tequilaron-***@public.gmane.org>
wrote:


I can't believe this so if anyone can point out the error in my ways please
do so.

$ cat Test.java
import java.util.Date;
import java.text.SimpleDateFormat;
import java.util.TimeZone;


public class Test {
public static void main(String[] args) throws Exception {
SimpleDateFormat formatter = new
SimpleDateFormat("MM/dd/yyyy'-'hh");
formatter.setTimeZone(TimeZone.getTimeZone("GMT"));
formatter.setLenient(false);


Date d1 = formatter.parse("10/10/2013-00");
System.out.println(d1);
}
}

$ /usr/java/jdk1.6.0_24/bin/javac Test.java

$ /usr/java/jdk1.6.0_24/bin/java -cp . Test
Wed Oct 09 17:00:00 PDT 2013

$ /usr/java/jdk1.7.0_45/bin/java -cp . Test
Exception in thread "main" java.text.ParseException: Unparseable date:
"10/10/2013-00"
at java.text.DateFormat.parse(DateFormat.java:357)
at Test.main(Test.java:11)

!?!?!?
still hunting for my own hints/answers but in case someone already hit this
please share. :)
--
Robert Hall
robertwadehall-***@public.gmane.org
Loading...