How do I round a number in JSTL?

Viewed 61652

I'm doing a division in a JSP and I'd like to round the result - how should I do this?

i.e.

<c:set
  var="expiry"
  value="${(expire.time - now.time) / (60 * 1000)}"/>

...how do I round the result?

Thanks,

5 Answers

With the current EL version you can use

<c:set var="expiry"
value="${Math.round( (expire.time - now.time) / (60 * 1000) )}"/>

or

<c:set var="expiry"
value="${Math.floor( (expire.time - now.time) / (60 * 1000) )}"/>
Related