Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

NumberFormat (22,34,12,546.08)  RSS feed

 
Tausif Khanooni
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all..
I m trying to display my number in (22,34,12,546.08) format.
its indian format. but i m not able to get this..
can any one help me out displaying my value in above format??
I m trying this way
NumberFormat form = NumberFormat.getInstance(locale);
System.out.println(form.format("223412546.08") );
it gives me the output of 223,412,546.08
plz any one help me in this regards
Tausif
 
Abhik Sarkar
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
According to the JavaDoc for DecimalFormat
The grouping separator is commonly used for thousands, but in some countries it separates ten-thousands. The grouping size is a constant number of digits between the grouping characters, such as 3 for 100,000,000 or 4 for 1,0000,0000. If you supply a pattern with multiple grouping characters, the interval between the last one and the end of the integer is the one that is used. So "#,##,###,####" == "######,####" == "##,####,####".

It would therefore seem that what you are trying (displaying in lacs) is not possible using the standard classes.
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Perhaps you could roll-your-own
Something like this, but it assumes the input format ends ".##"
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!