JDK-8217313 : The range of Japanese era is not correct when parsing from string
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.util:i18n
  • Affected Version: 11.0.2
  • Priority: P4
  • Status: Resolved
  • Resolution: Not an Issue
  • Submitted: 2019-01-17
  • Updated: 2019-01-17
  • Resolved: 2019-01-17
Related Reports
Relates :  
Description
System.out.println(
  DateTimeFormatter.ofPattern("u-M-d").format(
    DateTimeFormatter.ofPattern("Gy���M���d���")
      .withChronology(JapaneseChronology.INSTANCE)
      .parse("������31���5���1���")));

System.out.println(
  new SimpleDateFormat("Y-M-d", Locale.US).format(
    new SimpleDateFormat("Gy���M���d���", new Locale("ja","JP","JP"))
      .parse("������31���5���1���")))

Expected Result: 
  java.time.format.DateTimeParseException
  java.text.ParseException

Actual Result: 
  2019-5-1
  2019-5-1


Comments
In both cases, the default parsing is done leniently. In order to strictly parse the date string, the code need to specify .withResolverStyle(ResolverStyle.STRICT) for java.time, and SDF.setLenient(false) for java.text.
17-01-2019