10 Replies Latest reply: Oct 25, 2009 10:02 AM by 800343 RSS

    SimpleDateFormat Problem

    800343
      Hi

      I ran into a strange error today with SimpleDateFormat .

      In the following code:
      SimpleDateFormat format =
                  new SimpleDateFormat("yyyyMMddHHmmss");
                format.setLenient(false);
                try 
                {
                     Date date = format.parse("19850414000000");
                } 
                catch (ParseException e) 
                {
                     e.printStackTrace();
                }
      I receive an exception:
      java.text.ParseException: Unparseable date: "19850414000001"
           at java.text.DateFormat.parse(Unknown Source)
           at test.MainClass.main(MainClass.java:101)

      Could someone please tell me whats wrong with the date: 19850414000001 ?
      Actually after checking some more, all the times between 19850414000000 and 19850414005959 give this error while for example 19850414010000 or 19850413235959 work fine.
      Also this only happens for setLenient(false).

      What happened on the 14th of april 1985 that the Parser doesn't want to talk about?

      Thanks
      Aharon