File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSP and the fly likes fmt:formatNumber and grouping separator Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "fmt:formatNumber and grouping separator" Watch "fmt:formatNumber and grouping separator" New topic
Author

fmt:formatNumber and grouping separator

Egil Poma
Ranch Hand

Joined: Nov 23, 2002
Posts: 40
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

Joined: Nov 24, 2005
Posts: 14688
    
  16

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.



[My Blog]
All roads lead to JavaRanch
Egil Poma
Ranch Hand

Joined: Nov 23, 2002
Posts: 40
So it's not possible to set a pattern that simply creates a space for every thousand?
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14688
    
  16

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

Joined: Nov 23, 2002
Posts: 40
Ok, thanks!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: fmt:formatNumber and grouping separator