I have a date format like “MMMM dd, yyyy” and i am using <fmt:formatDate value="${purchaseDate}" pattern="MMMM dd, yyyy"/> and i have to compare this with the current date and check whether the purchase date is less than a year from current date or not?? Any suggestion how this can be done…
I have a date format like MMMM dd, yyyy and i am using <fmt:formatDate
Share
I think you would have to resort to
scriptlets<% //... your code ... %>in this case.And if you go with
scriptletsthen it would be simple Java Data comparison as shown here.You can also create a method in a utility class with comparison logic and then call it from your JSP.
I personally don’t prefer
scriptletsin my JSP code, so:requestand pass it on to JSP. But this depends on how much logic you would need to do after this simple comparison.So, if you really need to go with comparing dates in JSP then I guess
scriptletswould be the only way to go.Hope this gives some food for thought.