# milliseconds to hh:mm:ss format

Brian Percival

Ranch Hand

Posts: 163

posted 9 years ago

You can do arithmetic operations in EL if I'm not mistaken. And ordinary arithmetic operations are what you need here. Milliseconds = number mod 1000, subtract milliseconds from number and divide it by 1000, seconds = number mod 60, subtract seconds from number and divide it by 60, and so on.

Brian Percival

Ranch Hand

Posts: 163

posted 9 years ago

This is what I got. Hope someone can clarify this is true. However it displays decimals. How do I coerce the values as integers ?

<c:set var="dursec" value="${(ep.duration - (ep.duration mod 1000))/1000}" />

<c:set var="durhr" value="${(dursec - (dursec mod 3600)) / 3600}" />

<c:set var="temp" value="${(dursec - (durhr *3600))}" />

<c:set var="durmin" value="${ (temp - (temp mod 60)) / 60 }" />

<c:set var="dursec" value="${dursec-durmin*60-durhr*60}" />

${durhr} ${durmin} ${dursec}

This is what I got. Hope someone can clarify this is true. However it displays decimals. How do I coerce the values as integers ?