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

Formatter returns unexpected strings if locale is null.

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P3
    • Resolution: Fixed
    • Affects Version/s: 9
    • Fix Version/s: 9
    • Component/s: core-libs
    • Labels:
    • Subcomponent:
    • Introduced In Build:
      b122
    • Resolved In Build:
      b125
    • Verification:
      Verified

      Description

      Build: 9 122
      Steps to reproduce:
      1. Construct a new formatter with a null locale
      2. Format a Calendar and then check the result.

      Actual result:
      date/time is formatted to unreadable string. such as \u940f\ufffd

      Expected result:
      the result should be date/time string, Tuesday or May, etc.

      Sample code:
      //construct a new formatter
      Formatter f = new Formatter(new StringBuilder(), (Locale)null);
      //create a new calendar
      Calendar c1 = new GregorianCalendar(new SimpleTimeZone(-8 * 60 * 60 * 1000, TimeZone.getAvailableIDs(-8 * 60 * 60 * 1000)[0]), Locale.US);
      //set the date/time for the calendar
      c1.set(1995, 4, 23, 19, 48, 34);
      //format the calendar
      f.format("%ta", c1);
      //Expected result should be Tue, now the result is \u940f\ufffd
      System.out.println(f.toString());

      Additional:
      This issue doesn't reproduce in JDK 8u76, formatter returns "Tue" as expected.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                naoto Naoto Sato
                Reporter:
                yliu Johnny Liu (Inactive)
              • Votes:
                0 Vote for this issue
                Watchers:
                5 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: