Created
September 11, 2014 14:22
-
-
Save laxman954/b5f3779e28131218f9e2 to your computer and use it in GitHub Desktop.
Format day like 1st,2nd,3rd.. in JSP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%@ tag body-content="empty" trimDirectiveWhitespaces="true"%> | |
<%@ attribute name="day" required="true" type="String"%> | |
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> | |
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%> | |
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%> | |
<fmt:parseNumber var="n" type="number" value="${day}" /> | |
${day} | |
<sup> | |
<c:choose> | |
<c:when test="${n >= 11 && n <= 13}">th </c:when> | |
<c:when test="${n%10 == 1}">st </c:when> | |
<c:when test="${n%10 == 2}">nd </c:when> | |
<c:when test="${n%10 == 3}">rd </c:when> | |
<c:otherwise>th</c:otherwise> | |
</c:choose> | |
</sup> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment