Without using scriptlets, what’s the correct way for doing date arithmetic in JSP?
Here are examples what I’m trying to do:
- Get current year (YYYY)
- Subtract current year by one to get previous year (YYYY)
Thanks!
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Use
<jsp:useBean>to construct newDate. Use JSTL<fmt:formatDate>to get the year out of it. Use EL to substract it.Result:
Note that the pattern for full year is
yyyy, notYYYY.