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

Locale.getDefault() returns wrong Locale for Java SE 7

    XMLWordPrintable

    Details

    • Subcomponent:
    • Introduced In Version:
      7
    • Resolved In Build:
      b04
    • CPU:
      generic, x86
    • OS:
      windows, windows_xp, windows_vista, windows_7

      Backports

        Description

        FULL PRODUCT VERSION :
        java version "1.7.0"
        Java(TM) SE Runtime Environment (build 1.7.0-b147)
        Java HotSpot(TM) Client VM (build 21.0-b17, mixed mode, sharing)

        ADDITIONAL OS VERSION INFORMATION :
        Microsoft Windows XP [Version 5.1.2600]
        Microsoft Windows [Version 6.1.7600]

        EXTRA RELEVANT SYSTEM CONFIGURATION :
        Locale on Windows is set to "English (United Kingdom)" under "standards and formats" and "Language for non-Unicode programs". Location is set to "United Kingdom"

        A DESCRIPTION OF THE PROBLEM :
        The Locale returned from Locale.getDefault() is en_US when it shoud be en_GB

        This goes wrong on switching to version 1.7.0. Running the same software on the same environment under 1.6.0_26 and earlier it worked as expected.

        The result is that all the Locale specific output of times and dates in our software comes out wrong for our UK customers - today is 8/2/11 when it should be 02/08/11 etc

        REGRESSION. Last worked in version 6u26

        STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
        Set all the locale settings under Windows to "English (United Kingdom)". I have tried this on both Windows XP and Windows 7

        Run this code and compare the results for 1.6 and 1.7:

        System.out.println("java.version = " + System.getProperty("java.version"));
        System.out.println("Locale.getDefault() = " + Locale.getDefault());

        My output:

        >"C:\Program Files\Java\jre6\bin\java" nonguitestrig.Main
        java.version = 1.6.0_26
        Locale.getDefault() = en_GB

        >"C:\Program Files\Java\jre7\bin\java" nonguitestrig.Main
        java.version = 1.7.0
        Locale.getDefault() = en_US


        EXPECTED VERSUS ACTUAL BEHAVIOR :
        EXPECTED -
        The call should return the Locale set in the OS as it did under 1.6, i.e. en_GB
        ACTUAL -
        Java 1.7 returns a different result to 1.6, en_US

        REPRODUCIBILITY :
        This bug can be reproduced always.

        ---------- BEGIN SOURCE ----------
        import java.util.Locale;

        public class Main {
            public static void main(String[] args) {
        System.out.println("java.version = " + System.getProperty("java.version"));
        System.out.println("Locale.getDefault() = " + Locale.getDefault());
            }
        }
        ---------- END SOURCE ----------

          Attachments

            Issue Links

              Activity

                People

                Assignee:
                naoto Naoto Sato
                Reporter:
                webbuggrp Webbug Group
                Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                  Dates

                  Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: