JSTL padding int with leading zeros

Viewed 13091

I'm trying to use JSTL to build a form. I have a select input for the months but I need the months to always be two digits i.e. padded left with a Zero for 1-9.

I have this but obvious it doesn't give me what I want.

<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
    <select class="formInput">
        <c:forEach var="i" begin="1" end="12" step="1" varStatus ="status">
            <option><fmt:formatNumber pattern="##" value="${i}" /></option>
        </c:forEach>
    </select>

This has to have been done before but I can't find an example after a bit of searching.

1 Answers
Related