Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

fmt:formatNumber and grouping separator

 
Egil Poma
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want the code below to print 12 900 (with the space) provided the correct pattern off course:


I've been trying to come up with a pattern for this, but it's more difficult than I first thought. Can someone please help me out?
[ January 07, 2008: Message edited by: Egil Poma ]
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think that the problem here is that the group separator cannot be configured in JSTL. The Locale's group separator will be used. What you could do is to reverse the value, and separate groups of digits with spaces (I assume each group is 3 digit wide). Here is a sample, which you could put in a custom tag file. There may be other simpler ways to do it.

 
Egil Poma
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So it's not possible to set a pattern that simply creates a space for every thousand?
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you use a pattern such as "#,###", it will separate numbers with the Locale's group separator. So unless you are using a Locale whose separator is blank (are there any ?), I don't think you can use formatNumber to do this.
 
Egil Poma
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok, thanks!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic