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

java.util.Locale.toString() method works wrong.

    Details

      Description



      Name: avC70361 Date: 06/10/98



        The java.util.Locale.toString method works wrong when its language and variant
      fields are not empty and country field is empty. The method doesn't show
      variant field, although the language field is not empty (the only condition provided
      in the specs not to show the variant field is when both language and country fields
      are empty).

        here is a test demonstrating the bug.
      -----------LocaleToStringTest.java--------
      import java.util.Locale;

      public class LocaleToStringTest {
        public static void main(String args[]) {
          String language = "en";
          String country = "";
          String variant = "WIN";

          Locale locale = new Locale(language, country, variant);

          String result = locale.toString();

          if (!result.equals(language + "_" + variant)) {
            System.out.println(
              "Failed: Locale.toString() returns wrong result : \""
                + result + "\"\n"
              + "for a locale with language \"" + language + "\""
              + ", country \"" + country + "\""
              + " and variant \"" + variant + "\""
            );
          } else {
            System.out.println("Passed");
          }
        }
      }
      -----------The test output-----------
      > java LocaleToStringTest
      Failed: Locale.toString() returns wrong result : "en"
      for a locale with language "en", country "" and variant "WIN"

      ======================================================================

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                rgillamsunw Richard Gillam (Inactive)
                Reporter:
                ovlasov Oleksandr Vlasov (Inactive)
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: