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

ResourceBundle.getLocale() method does not return the correct locale

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not an Issue
    • Icon: P4 P4
    • None
    • 1.3.0
    • core-libs



      Name: boT120536 Date: 05/06/2001


      java version "1.3.1-beta"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.1-beta-b15)
      Java HotSpot(TM) Client VM (build 1.3.1beta-b15, mixed mode)

      ResourceBundle.getLocale() method does not return the locale used in the
      ResourceBundle.getBundle() method. The locale returned has an empty string as
      country code and language code and when compared with the locale used in the
      getBundle() method with Locale.equals(), false is returned.

      Here is a sample code to demonstrate the issue:

      import java.util.Locale;
      import java.util.ResourceBundle;

      public class ResourceBundleLocale
      {
          public static void main( String[] args )
          {
              ResourceBundle resourceBundle = ResourceBundle.getBundle( "test" , Locale.CANADA );
              Locale locale = resourceBundle.getLocale();
              if ( locale.equals( Locale.CANADA ) )
              {
                  System.out.println( " Locale set in Resource Bundle. " );
              }
              else
              {
                  System.out.println( " Locale NOT set in Resource Bundle. " );
              }
              System.out.println(" locale.getCountry() " + locale.getCountry()
                          + " locale.getLanguage() " + locale.getLanguage() );
              System.out.println( " getString test " + resourceBundle.getString(
      "test" ) );
          }
      }

      Here is the ResourceBundle class:

      public class test extends java.util.ListResourceBundle
      {
          public Object[][] getContents() { return( contents ); }

      static final Object[][] contents =
      {
              { "test" , "Test" } ,
          };
      }
      (Review ID: 121040)
      ======================================================================

            nlindenbsunw Norbert Lindenberg (Inactive)
            bonealsunw Bret O'neal (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: