Search code examples
javadatejspservletsjstl

Getting Date in JSTL using EL Expressions


As of I know that

<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>

<jsp:useBean id="now" class="java.util.Date" />

<fmt:formatDate var="year" value="${now}" pattern="yyyy" />

<p>Current year: ${year}</p>

this will gives current Year but I needed to check if the current date is < 10th of the current month or not?


Solution

  • This is the closest I could code.

    <%@ page import="java.time.LocalDate" %>
    <%
        pageContext.setAttribute("lDate", LocalDate.now());
    %>
    Is today before the 10th of the month? ${lDate.dayOfMonth < 10}