jsp - JSTL Number parsing error -
i need current year integer value (e.g. 2015) stored in variable in jsp page.
jstl tags i'm using:
<jsp:usebean id="date" class="java.util.date" /> <fmt:formatdate var="currentyear" value="${date}" pattern="yyyy" /> <fmt:parsenumber var="currentyear" integeronly="true" type="number" value="${currentyear}" parselocale="en-us"/>
and error i'm facing in tomcat log:
[javax.servlet.servletexception: javax.servlet.jsp.jspexception: in <parsenumber>, value attribute can not parsed: "wed apr 29 00:42:30 cest 2015"] root cause java.text.parseexception: unparseable number: "wed apr 29 00:42:30 cest 2015" @ java.text.numberformat.parse(numberformat.java:350) @ org.apache.taglibs.standard.tag.common.fmt.parsenumbersupport.doendtag(parsenumbersupport.java:164) @ org.apache.jsp.new_.reports_jsp._jspx_meth_fmt_005fparsenumber_005f0(reports_jsp.java:242) @ org.apache.jsp.new_.reports_jsp._jspservice(reports_jsp.java:136)
am doing wrong?
strangest thing see error in log: if load page, works should , see correct current year.
in end used alternative workaround problem:
<jsp:usebean id="date" class="java.util.date" /> <c:set var="currentyear" value="${date.getyear() + 1900}" />
Comments
Post a Comment