【发布时间】:2012-01-21 17:25:30
【问题描述】:
请原谅我今晚放屁,但出于某种原因...这是我现在能想到的最好的解决方案,即现在使用 JSTL 获得 BigDecimal 的 ABS...除了数学技巧之外没有任何数学技巧ABS也是。我必须保持精确。
我知道有更好的方法来处理它...您有什么建议?任何谷歌搜索都会在 formatNumber 上获取帮助并处理 delta/negatives 的货币。
<c:forEach items="${arr}" var="cursor" varStatus="itemsRow">
<c:choose>
<c:when test="${cursor.value < 0}">
<td width="75px" align="right">
<fmt_rt:formatNumber pattern="#,###,###,###.##" value="${cursor.value * -1}" minFractionDigits="2"/></td>
</c:when>
<c:otherwise>
<td width="75px" align="right">
<fmt_rt:formatNumber pattern="#,###,###,###.##" value="${cursor.value}" minFractionDigits="2"/></td>
</c:otherwise>
</c:choose>
</c:forEach>
【问题讨论】:
-
您的示例看起来像 HTML,其中包含一些 PHP 解析。
-
@Jon 哪个部分看起来像 PHP?在我看来像 JSP。
标签: java jstl bigdecimal absolute