i'm trying to use DateFormat.
If i write this in a jsp page i have no problem
DateFormat df = new SimpleDateFormat("dd");
String print= df.format(new Date());
out.print(print);
If i try to write this in a javabean
public class Date {
String printDate="";
public String DataAttualeFormatoItaliano (){
DateFormat df = new SimpleDateFormat("dd");
printDate=df.format(new Date());
return printDate;
}
}
and in my jsp page i use the javabean this way
<jsp:useBean id="Data" class="Jeans.Date"/>
<%
out.print(Data.DataAttualeFormatoItaliano());
%>
I get this error
org.apache.jasper.JasperException: java.lang.IllegalArgumentException: Cannot format given Object as a Date
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:502)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:430)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
Does anybody know why? Thank you