2

How to display positive value or absolute value of a number in jstl?

<fmt:formatNumber value="${-85}" format="%" /> <!-- should convert -85 to 85 -->
0

3 Answers 3

7

You can use el:

${value < 0 ? -value:value}

or Create a custom EL function which delegates to Math#abs(int).

0

create you custom EL function in your code.

1
  • 4
    yes, that is what the answer to the duplicate question suggests. Apr 16, 2014 at 5:54
0

Try adding the type attribute to the expression.

<fmt:formatNumber type="currency" value="${-85}" />

Not the answer you're looking for? Browse other questions tagged or ask your own question.