1

When I used date format in jsp page in tomcat 6 or 7 which is running with jre 7 it doesn't shown any error.

But when I uploaded my code in to the other machine which is running with jre 6 or 5 it's showing bellow error. In my code I imported java.util.java.text package also.

     org.apache.jasper.JasperException: An exception occurred processing JSP page       /entsug.jsp at line 24

      21: String imag =(String)session.getAttribute("image");
      22: String frrr =(String)session.getAttribute("frrr");
      23: String moto = request.getParameter("sugge");
      24: java.text.DateFormat df = new java.text.SimpleDateFormat("dd/MM/YYYY   HH:mm"); 
      25: String da=df.format(new java.util.Date()); 
      26: 
      27: 

Stacktrace:

       org.apache.jasper.servlet.JspServletWrapper.handleJspException
       (JspServletWrapper.java:510)
   org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:419)
   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)

root cause

        java.lang.IllegalArgumentException: Illegal pattern character 'Y'
    java.text.SimpleDateFormat.compile(Unknown Source)
    java.text.SimpleDateFormat.initialize(Unknown Source)
    java.text.SimpleDateFormat.<init>(Unknown Source)
    java.text.SimpleDateFormat.<init>(Unknown Source)
    org.apache.jsp.entsug_jsp._jspService(entsug_jsp.java:88)
    org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:377)
    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)
3
  • Its problem in jre version. you use proper jre version. Commented Mar 15, 2014 at 8:18
  • i think all answers are right..might as well give a vote up for every1.. Commented Mar 15, 2014 at 10:59
  • @User211 vote up requires 15 reputation Commented Mar 15, 2014 at 11:04

3 Answers 3

2

comparing the API Docs for Java 6 and Java 7 holds the answer:

SimpleDateFormat SE 6 only allows lower case 'y' to display the year. SimpleDateFormat SE 7 additionally allows capital case 'Y' to display what is called "Week year"

Good luck!

Sign up to request clarification or add additional context in comments.

1 Comment

(And you definitely don't want week-year here...)
0

Try small 'y' instead of capital think that works.

Comments

0

Try this

java.text.DateFormat df = new java.text.SimpleDateFormat("dd/MM/yyyy  HH:mm"); 

Lower case y

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.