how to format number for positive value or absolute value in jstl? [duplicate]

StackOverflow https://stackoverflow.com/questions/23100995

  •  04-07-2023
  •  | 
  •  

Question

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

<fmt:formatNumber value="${-85}" format="%" /> <!-- should convert -85 to 85 -->
Était-ce utile?

La solution

You can use el:

${value < 0 ? -value:value}

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

Autres conseils

create you custom EL function in your code.

Try adding the type attribute to the expression.

<fmt:formatNumber type="currency" value="${-85}" />
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top