You are viewing a plain text version of this content. The canonical link for it is here.
Posted to taglibs-user@tomcat.apache.org by Brian Buckley <br...@attbi.com> on 2003/04/28 18:28:46 UTC
, zero divide
When one uses the <fmt:formatNumber ../> where the value of the number is a
zero divide, a "?" is sent to output.
Is there a convenient way to make <fmt:formatNumber/> print an alternate
message?
Brian
-------------------
<%-- prints "?" but we want "Zero divide" --%>
<fmt:formatNumber value="${5 / 0 }" pattern="0.00%;" />
---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: taglibs-user-help@jakarta.apache.org
RE: , zero divide
Posted by Mark Starmer <ma...@markstarmer.co.uk>.
I've (foolishly) not really played much with the format tags but looking
at the syntax you can do a great deal with patterns etc. like you say.
There do seem to be hundereds of functions in with it. One I do like is
the <fmt:setLocale /> which can be used to format dates and numbers for
every country in the world...
Best Regards
Mark Starmer
http://www.markstarmer.co.uk
-----Original Message-----
From: Brian Buckley [mailto:briankbuckley@attbi.com]
Sent: 28 April 2003 19:21
To: Tag Libraries Users List
Subject: Re: <fmt:formatNumber ../>, zero divide
> Try this...
>
> <c:set var="pagNonZeroVal">
> <fmt:formatNumber value="${5 / 0 }" pattern="0.00%;" /> </c:set>
> <c:if test="${pagNonZeroVal == '?'}">
> <c:set var="pagNonZeroVal">
> <!--Display the output value you want-->
> 0
> </c:set>
> </c:if>
>
> You may need to play with the syntax, that should work though
Thanks, Mark. Your solution will get it done.
I was thinking about all the numberformat options available in an Excel
spreadsheet, and was hoping (unrealistically probably) one could enter
some fancy pattern or other attribute to the fmt:formatNumber tag to do
it even more succinctly.
---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: taglibs-user-help@jakarta.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: taglibs-user-help@jakarta.apache.org
Re: , zero divide
Posted by Brian Buckley <br...@attbi.com>.
> Try this...
>
> <c:set var="pagNonZeroVal">
> <fmt:formatNumber value="${5 / 0 }" pattern="0.00%;" />
> </c:set>
> <c:if test="${pagNonZeroVal == '?'}">
> <c:set var="pagNonZeroVal">
> <!--Display the output value you want-->
> 0
> </c:set>
> </c:if>
>
> You may need to play with the syntax, that should work though
Thanks, Mark. Your solution will get it done.
I was thinking about all the numberformat options available in an Excel
spreadsheet, and was hoping (unrealistically probably) one could enter some
fancy pattern or other attribute to the fmt:formatNumber tag to do it even
more succinctly.
---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: taglibs-user-help@jakarta.apache.org
RE: , zero divide
Posted by Mark Starmer <ma...@markstarmer.co.uk>.
Try this...
<c:set var="pagNonZeroVal">
<fmt:formatNumber value="${5 / 0 }" pattern="0.00%;" />
</c:set>
<c:if test="${pagNonZeroVal == '?'}">
<c:set var="pagNonZeroVal">
<!--Display the output value you want-->
0
</c:set>
</c:if>
You may need to play with the syntax, that should work though
-----Original Message-----
From: Brian Buckley [mailto:briankbuckley@attbi.com]
Sent: 28 April 2003 17:29
To: taglibs-user@jakarta.apache.org
Subject: <fmt:formatNumber ../>, zero divide
When one uses the <fmt:formatNumber ../> where the value of the number
is a zero divide, a "?" is sent to output.
Is there a convenient way to make <fmt:formatNumber/> print an alternate
message?
Brian
-------------------
<%-- prints "?" but we want "Zero divide" --%> <fmt:formatNumber
value="${5 / 0 }" pattern="0.00%;" />
---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: taglibs-user-help@jakarta.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: taglibs-user-help@jakarta.apache.org