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

Adjacent value parsing not supported for Localized Patterns

XMLWordPrintable

    • b151
    • generic
    • generic

      FULL PRODUCT VERSION :


      A DESCRIPTION OF THE PROBLEM :
      DateTimeFormatter.ofPattern("YYYYww").parse("201550") fails with "java.time.format.DateTimeParseException: Text '201550' could not be parsed at index 0" and I think it shouldn't.
      The same text and pattern work with SimpleDateFormat, so does DateTimeFormatter.ofPattern("YYww").parse("1550").
      It fails in java.time.format.DateTimeFormatterBuilder.NumberPrinterParser.parse(DateTimeParseContext, CharSequence, int), line 2695
      http://hg.openjdk.java.net/jdk8u/jdk8u/jdk/file/6ea3aea950d1/src/share/classes/java/time/format/DateTimeFormatterBuilder.java#l2695
      However, parsing "2015 50" with "YYYY ww" works fine.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      DateTimeFormatter.ofPattern("YYYYww").parse("201550")

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      {WeekBasedYear[WeekFields[MONDAY,4]]=2015, WeekOfWeekBasedYear[WeekFields[MONDAY,4]]=50},ISO
      ACTUAL -
      IllegalArgumentException: Text '201550' could not be parsed at index 0

      REPRODUCIBILITY :
      This bug can be reproduced always.

            ntv Nadeesh Tv
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            11 Start watching this issue

              Created:
              Updated:
              Resolved: