JDK-8024257 : Locale.getDefault() should be replaced by Locale.getDefault(Category.DISPLAY) where appropriate
  • Type: Enhancement
  • Component: core-libs
  • Sub-Component: java.util:i18n
  • Priority: P4
  • Status: Open
  • Resolution: Unresolved
  • Submitted: 2013-09-04
  • Updated: 2017-06-19
Related Reports
Relates :  
See recommendation from Naoto in 

Just one comment. When you are retrieving the default locale, please use 
Locale.getDefault(Locale.Category.DISPLAY) which returns the default 
locale for displaying translatable names.

Locale.Category was introduced in JDK7 where the user can set the 
default locales separately for UI display names and Formatting. In your 
case, the resource bundle seems to contain user visible localizable 
strings, so I suggested using getDefault() with Locale.Category.DISPLAY 
specifically. That way the user would see the string in the correct 
language even on any custom default locale environment.

There are possibly several places in the corelibs where  Locale.getDefault(Category.DISPLAY) should be preferred to Locale.getDefault().

e.g. Logging, ResourceBundle etc...
Suggested during review of JDK-8016127.