JDK-6452035 : request for Locale.parseLocale()
  • Type: Enhancement
  • Component: core-libs
  • Sub-Component: java.util:i18n
  • Affected Version: 6
  • Priority: P4
  • Status: Closed
  • Resolution: Won't Fix
  • OS: windows_xp
  • CPU: x86
  • Submitted: 2006-07-24
  • Updated: 2011-06-22
  • Resolved: 2011-06-22
Related Reports
Relates :  
Relates :  
Description
A DESCRIPTION OF THE REQUEST :
As already done for many other classes (e.g. any Number class) it would be fine if java.util.Locale also provides a method to parse a Locale-String like "en_GB"

JUSTIFICATION :
nearly each developer will come to the point to parse a locale and writes his own solution. It is not much work to integrate it in the Locale class itself and would make it more usable

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Locale locale = Locale.parseLocale("en");
locale = Locale.parseLocale("en_GB");
locale = Locale.parseLocale("en-GB");
// ...
ACTUAL -
locale = myParseLocale("en_GB");

Comments
EVALUATION JDK7 now provides Locale.forLangaugeTag() that provides the equivalent functionality.
22-06-2011

EVALUATION Instead of having it as 'parseLocale()' method, this can be a more generic factory method, such as, Locale.getInstance(String localeid), where 'localeid' is a language tag defined in RFC3166bis.
25-07-2006