About Question enthuware.ocpjp.v11.2.1432 :

Help and support on OCA OCP Java Programmer Certification Questions
1Z0-808, 1Z0-809, 1Z0-815, 1Z0-816, 1Z0-817

Moderator: admin

Post Reply
sohamdatey22
Posts: 28
Joined: Sun Sep 11, 2022 3:55 am
Contact:

About Question enthuware.ocpjp.v11.2.1432 :

Post 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.
Last edited by sohamdatey22 on Fri Sep 30, 2022 7:17 am, edited 2 times in total.

admin
Site Admin
Posts: 10398
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

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

Post 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.

sohamdatey22
Posts: 28
Joined: Sun Sep 11, 2022 3:55 am
Contact:

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

Post 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.

Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 4 guests