The value you're sending to the page is presumably 5.09 (or -5.95).  
Percentage formatting in JSTL, as in Java, treats your value as a
multiple; thus, to format as a percentage, it multiplies by 100.  (That
is, 5% is really .05; 500% indicates a multiplier of 5.)

Since your need doesn't really coincide with Java's percentage formatting
(especially since you need a custom '+' before positive numbers), using a
custom pattern -- as you've done -- is probably your best bet.

-- 
Shawn Bayern
"JSTL in Action"   http://www.jstlbook.com

On Thu, 25 Jul 2002 [EMAIL PROTECTED] wrote:

> Hi all
> 
> I just tried formatting a percentage change for stocks. I was looking for
> something like
> 
> +5.09%
> -5.95%
> 
> Trying
> 
> <fmt:formatNumber value="${stock.percentageChange}" type="percent"/>
> 
> resulted in
> 
> 509%
> -595%
> 
> which seems very strange to me - who formats percentages like this? Also,
> how to switch on the "+" for positive values?
> In the end, I used
> 
> <fmt:formatNumber value="${stock.percentageChange}"
> pattern="+#0.00;-#0.00"/>%
> 
> Hmmm... can I change the percentage formatting somehow?
> 
> Best regards,
> Eric
> 
> 
> --
> To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
> 


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to