3 Replies Latest reply: Mar 22, 2014 11:06 AM by java4ever RSS

    Date Parsing Issues with TZ  ?

    java4ever

      Hi Experts,

       

        I have a date in the following String format "2013-03-28,19:37:52.00+00:00"  and post processing I am converting this to following String as per prevailing logic "2013-03-28,19:37:52.00+0000"  (This is existing code and no changes have been Made here for last few years)
      And the using this SDFormat i.e  new SimpleDateFormat("yyyy-MM-dd,HH:mm:ss.Sz")   for conversion to Date Object

       

      We are suddenly getting this exception now can't figured out what has changed ?

       

      java.text.ParseException: Unparseable date: "2013-03-28,19:37:52.00+0000"

      at java.text.DateFormat.parse(DateFormat.java:357)

       

      Kindly suggest.

       

       

      --

      j4r

        • 1. Re: Date Parsing Issues with TZ  ?
          rp0428
          Kindly suggest.

          Ok - I suggest that if you want help with code that you actually SHOW US the code that you want help with.

           

          We can't debug code that we can't see. Post the code that manifests the problem and a copy of the session showing how that code is executed.

           

          Also post the full Java version you are using.

          • 2. Re: Date Parsing Issues with TZ  ?
            java4ever

            Input String="2013-03-28,19:37:52.00+0000"

             

            We have this SDF - "yyyy-MM-dd,HH:mm:ss.Sz", Which was working previously and now for some reason is giving the exception as shown above and failing to parse the date


            Java version is 1.7.0_u51

             

             

            Java Code:

             

            Date dt = new Date(); 

            try {

            dt = alert.parse("yyyy-MM-dd,HH:mm:ss.Sz"); alert is a String holding the value shown in input string

            } catch (ParseException e)

              {

            e.printStackTrace(); //Code ends up here and throws the error shown above in Original post

              }

            • 3. Re: Date Parsing Issues with TZ  ?
              java4ever

              The Fix is found
              In case anyone stumbles upon this.

               

              The SDF format to be used under Java 1.7 was

              SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd,HH:mm:ss.SSZ")

               

               

              This is a bit curious why the old format worked for so long and suddenly with a upgrade it went sideways, could be a issue or some thing not sure

              leave it upto the experts.

               

              Thanks

              j4r