Hello all,

I'm trying to get the integer portion of the ceiling of a number using
JSTL 1.2 fmt tags on Tomcat 6.x, JavaSE 6.x.

So, if my number is 1.2 , the result expected is 2 (no fractions)  or
if my number is 1.6 the result wanted is 2

In JavaSE 6 this can be accomplished with NumberFormat
      NumberFormat nf = NumberFormat.getIntegerInstance();

Math.ceil(1.2d) gives 2.0

I tried the following with JSTL fmt tags,

<fmt:formatNumber value="${1.2}" type="number" pattern="#"/> gives 1
<fmt:formatNumber value="${1.6}" type="number" pattern="#"/> gives 2

<fmt:parseNumber value="${1.2}" type="number" integerOnly="true"/>  gives 1
<fmt:parseNumber value="${1.6}" type="number" integerOnly="true"/>  gives 1

The fmt:formatNumber or fmt:parsNumber do not have a roundingMode

This gives:
  <c:set var="mynum"><%=Math.ceil(1.2d)%></c:set>
  <fmt:formatNumber value="${mynum}" type="number" pattern="#"/>
the expected result 2 .

Or the ceiling (and other rounding modes) could be accomplished with a
custom tag.

I wish the fmt:formatNumber and fmt:parseNumber provide the
roundingMode attribute.


To unsubscribe, e-mail: taglibs-user-unsubscr...@jakarta.apache.org
For additional commands, e-mail: taglibs-user-h...@jakarta.apache.org

Reply via email to