Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Parsing date..?

 
mallikarjun dontamsetti
Ranch Hand
Posts: 246
Firefox Browser Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
I my form i am using jquery date picker and it gives date of formate "dd/mm/yyyy" the value is passed to servlet and i have to insert it into mySQL Db so i write faloowing code.



it is giving Exception like

  • java.text.ParseException: Unparseable date: "29/11/2011"
    at java.text.DateFormat.parse(DateFormat.java:337)
    at com.garnet.jobseeker.JobSeekerServlet.getGeneralInfoArguments(JobSeekerServlet.java:150)
    at com.garnet.jobseeker.JobSeekerServlet.doGet(JobSeekerServlet.java:79)
    at com.garnet.jobseeker.JobSeekerServlet.doPost(JobSeekerServlet.java:48)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
    at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
    at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
    at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:292)
    at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:175)
    at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3498)
    at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
    at weblogic.security.service.SecurityManager.runAs(Unknown Source)
    at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2180)
    at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2086)
    at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1406)
    at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
    at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)

  • please help me
     
    John Jai
    Rancher
    Posts: 1776
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    For the string "29/11/2011" shouldn't the format be "dd/MM/yyyy"?
     
    mallikarjun dontamsetti
    Ranch Hand
    Posts: 246
    Firefox Browser Oracle
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    John Jai wrote:For the string "29/11/2011" shouldn't the format be "dd/MM/yyyy"?


    I want the formate as "yyyy-MM-dd"(mySQL formate) for the above string.
     
    John Jai
    Rancher
    Posts: 1776
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Use parse() method first to convert the input string into date and then format it into required format using the format() method - SimpleDateFormat
     
    Harsha Smith
    Ranch Hand
    Posts: 287
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    The following code should give you some idea on how to do it.

     
    John Jai
    Rancher
    Posts: 1776
    • Likes 1
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    I usually do that using two formatters... I don't know if this is efficient though..

     
    mallikarjun dontamsetti
    Ranch Hand
    Posts: 246
    Firefox Browser Oracle
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    John jai, Harsha Smith thaanks...
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic