Page 1 of 1

About Question enthuware.ocpjp.v11.2.1432 :

Posted: Thu Sep 29, 2022 2:16 am
by sohamdatey22
The option 2, is misguiding,

You can set the Locale after constructing a DateFormat or a NumberFormat object and before using it to do country specific formatting.

we can actually, set the default local, calling, Locale.setDefault(Locale.US)

1. NumberFormat f = NumberFormat.getInstance();
2. Locale.setDefault(Locale.Category.FORMAT,Locale.US)
3. f.format(23456.56);

The first line formatter, will be always impacted by the line 2,
NumberFormat f = NumberFormat.getInstance(Locale.US);, this shall not get impacted by, the second line.

EDIT:
Hi, I tried the thing, it does not seem, to work,
The instance returned, in the 1st line does not seem to get impacted, by the second line.

Re: About Question enthuware.ocpjp.v11.2.1432 :

Posted: Thu Sep 29, 2022 8:54 am
by admin
You are changing the default locale. You are not changing the locale of NumberFormat.
But the case that you have highlighted is definitely interesting to know. I haven't tested it out though.

Re: About Question enthuware.ocpjp.v11.2.1432 :

Posted: Fri Sep 30, 2022 7:16 am
by sohamdatey22
Hi, I tried the thing, it does not seem, to work,
The instance returned, in the 1st line does not seem to get impacted, by the second line.