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.
About Question enthuware.ocpjp.v11.2.1432 :
Moderator: admin
-
- Posts: 28
- Joined: Sun Sep 11, 2022 3:55 am
- Contact:
About Question enthuware.ocpjp.v11.2.1432 :
Last edited by sohamdatey22 on Fri Sep 30, 2022 7:17 am, edited 2 times in total.
-
- Site Admin
- Posts: 10398
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocpjp.v11.2.1432 :
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.
But the case that you have highlighted is definitely interesting to know. I haven't tested it out though.
-
- Posts: 28
- Joined: Sun Sep 11, 2022 3:55 am
- Contact:
Re: About Question enthuware.ocpjp.v11.2.1432 :
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.
The instance returned, in the 1st line does not seem to get impacted, by the second line.
Who is online
Users browsing this forum: Bing [Bot] and 6 guests