Recently, I have had trouble comparing LocalDateTime instances using the predefined method isAfter().
I have tried the following in Eclipse and it works fine:
stock.getReserveDate().isAfter(LocalDateTime.now())
where stock is a JPA Entity with a LocalDateTime field that has a getter called getReserveDate().
Executing the following code in JSP(which I believe is identical to the line above) gives me a NullPointerException.
<c:when test="${!compStock.getReserveDate().isAfter(LocalDateTime.now())}">
<p>Stock is reserved!</p>
</c:when>
After debugging, I've managed to find out that the LocalDateTime.now()
part of my code is considered null
by JSP / JSTL but I have no idea why. This code works perfectly when ran in Eclipse but fails in a JSP.