Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8081794

ParsePosition getErrorIndex returns 0 for TimeZone parsing problem

    Details

    • Subcomponent:
    • Introduced In Version:
      8
    • Resolved In Build:
      b85
    • CPU:
      x86
    • OS:
      os_x
    • Verification:
      Verified

      Backports

        Description

        FULL PRODUCT VERSION :
        java version "1.8.0_40"
        Java(TM) SE Runtime Environment (build 1.8.0_40-b25)
        Java HotSpot(TM) 64-Bit Server VM (build 25.40-b25, mixed mode)

        ADDITIONAL OS VERSION INFORMATION :
        DarwinMacBook-Pro-7.local 14.3.0 Darwin Kernel Version 14.3.0: Mon Mar 23 11:59:05 PDT 2015; root:xnu-2782.20.48~5/RELEASE_X86_64 x86_64

        A DESCRIPTION OF THE PROBLEM :
        reporting on behalf a Stack Overflow user:
        http://stackoverflow.com/questions/30076349/simpledateformat-parse-returns-errorindex-as-0

        a malformed TimeZone will prevent parsing the date, but not set the correct errorIndex in ParsePosition

        REGRESSION. Last worked in version 6u43

        ADDITIONAL REGRESSION INFORMATION:
        claimed to be working in at least jdk1.6.0_38

        STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
        run the attach source code

        EXPECTED VERSUS ACTUAL BEHAVIOR :
        EXPECTED -
        parse position for error should be 21
        ACTUAL -
        parse position for error is 0, the date was not parsed. Provind for example an invalid month name does produce a correct error position of 3

        REPRODUCIBILITY :
        This bug can be reproduced always.

        ---------- BEGIN SOURCE ----------
          public static void main(String[] args) throws Exception {
            String date = "13 Jan 2005 21:45:34 ABC";
            String format = "dd MMM yyyy HH:mm:ss z";
            ParsePosition pp = new ParsePosition(0);
            pp.setIndex(0);
            SimpleDateFormat sd = new SimpleDateFormat(format, Locale.ENGLISH);
            Date d = sd.parse(date, pp);
            System.out.println(d);
            System.out.println("Error Index " + pp.getErrorIndex());
          }
        ---------- END SOURCE ----------

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  nkumar Naveen Kumar (Inactive)
                  Reporter:
                  webbuggrp Webbug Group
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  6 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved: