problem in internationalising numbers
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   venkatraman_arumugam
Posted On:   Thursday, October 13, 2005 02:30 AM

I am trying to internationlize numbers.I am not able to parse numbers with grouping separator.Following is the code piece. public class TestLocale { public static void main(String args[]) throws ParseException{ NumberFormat formatter=NumberFormat.getNumberInstance(Locale.FRANCE); DecimalFormat dd = (DecimalFormat)formatter; DecimalFormatSymbols ds = new DecimalFormatSymbols(Locale.FRANCE); System.out.println("Grouping separator"+ds.getGroupingSeparator()); dd.setDecimalFormatSymbols(ds); System.out.println(dd.parse("1234 7")); } } The group separator in F   More>>

I am trying to internationlize numbers.I am not able to parse numbers with grouping separator.Following is the code piece.


			
				public class TestLocale {
				

public static void main(String args[]) throws ParseException{

NumberFormat formatter=NumberFormat.getNumberInstance(Locale.FRANCE);

DecimalFormat dd = (DecimalFormat)formatter;

DecimalFormatSymbols ds = new DecimalFormatSymbols(Locale.FRANCE);

System.out.println("Grouping separator"+ds.getGroupingSeparator());

dd.setDecimalFormatSymbols(ds);

System.out.println(dd.parse("1234 7"));

}

}


The group separator in France locale is whitespace.When i print the above it is giving 1234 instead of 12347.Anything i am doing wrong ?

   <<Less

Re: problem in internationalising numbers

Posted By:   Anonymous  
Posted On:   Thursday, October 13, 2005 05:47 AM

I believe you don't need to call setDecimalFormatSymbols, since dd's locale is already set to France.

I thought the problem came from the position of the whitespace (it is a thousand separator!), but even in the right place, it doesn't work better.

The logic seems correct, since changing locale to ENGLISH and separator to comma gives correct results.

I wonder if this is a bug, like parse stopping to parse on a space even if this a valid separator.

Note: I checked dd.isGroupingUsed() and it is OK...

About | Sitemap | Contact