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

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

  •  04-07-2023
  •  | 
  •  

Pergunta

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

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

Solução

You can use el:

${value < 0 ? -value:value}

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

Outras dicas

create you custom EL function in your code.

Try adding the type attribute to the expression.

<fmt:formatNumber type="currency" value="${-85}" />
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top