TjDillashaw
TjDillashaw

Reputation: 817

How to set a double format by locale

I those input strings:

 10000,20
 4000,10
 5,400.20

I am trying to format them with locale:

nf = NumberFormat.getInstance(Locale.FRANCE);
double newLoc = nf.parse(split[5]).doubleValue();

And also like this:

   nf = NumberFormat.getInstance(Locale.ENGLISH);
    double newLoc = nf.parse(split[5]).doubleValue();

Result is: for Locale.FRANCE

5400.2 
4000.0 
10000.0

For Locale.ENGLISH

4000.0
10000.0
5400.0

But what in need is smth like this: for Locale.France

10 000,2 
4 000,1
5 400,2

And Locale.English

10,000.2
4,000.1
5,400.2

Upvotes: 3

Views: 605

Answers (1)

Vladyslav Sheruda
Vladyslav Sheruda

Reputation: 1876

You can't present double or float in format 10,000.2 or 10 000,2, this is String format. You can use for example String.format() method to do it. More info about this read here.

Upvotes: 3

Related Questions