java - What locale does DecimalFormat and DateFormat use by default? (why is it different to Locale.getDefault()?) -


when debugging application, if found decimalformat , dateformat set use nl_nl default, system locale seems en_us.

i found first evaluating:

new decimalformat().symbols.locale new simpledateformat().locale 

and second:

locale.getdefault() system.getproperty("user.country") system.getproperty("user.language") 

what happening there?

how can set formatters use locale default? (i'm writing unit tests , set specific locale without touching application code)

as of java 7, the default locale comes in 2 categories: "display" , "format". both set according environment. can found calling locale.getdefault(category).

besides system properties mentioned in question:

"user.country" "user.language" 

the following can present when running jvm:

"user.country.format" "user.language.format" "user.country.display" "user.language.display" 

the reason seems some os's allow independent localization settings displaying text , formatting dates, numbers , currency.

answering last question, calling locale.setdefault(locale) the default locale set categories.


Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -