Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

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.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8102249
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T23:11:47+00:00 2026-06-05T23:11:47+00:00

I have a starttime as textfield. I need to covert the String which I

  • 0

I have a starttime as textfield. I need to covert the String which I type in the text field to SQL date and store into database.

Default.xhtml

 Start Date 
 <h:inputText id="startdate" value="#{customer.start_date}" 
                size="20" required="true"
                label="startdate" >
            </h:inputText>

CustomerBean.java

      formatter = new SimpleDateFormat("dd/MM/yyyy");
      Date startDate = (Date)formatter.parse(CustomerBean.this.getStart_date());
      Date endDate = (Date)formatter.parse(CustomerBean.this.getEnd_date());
      @SuppressWarnings("deprecation")
    java.sql.Date startdate=new java.sql.Date(startDate.getDate());
      @SuppressWarnings("deprecation")
    java.sql.Date enddate=new java.sql.Date(endDate.getDate());
     System.out.println("Today is " +date );
     PreparedStatement ps 
        = con.prepareStatement(sql);
    ps.setDate(1,startdate);
    ps.setDate(2,enddate);

If I run this program I am getting the following error.

An Error Occurred:

  java.text.ParseException: Unparseable date: "19/06/2012"
 - Stack Trace

  javax.faces.el.EvaluationException: java.text.ParseException: Unparseable date:    "19/06/2012"
at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:102)
at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102)
at javax.faces.component.UICommand.broadcast(UICommand.java:315)
at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:794)
at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1259)
at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:593)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:240)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:164)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:462)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:562)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:395)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:250)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:188)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:166)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:302)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:619)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T23:11:49+00:00Added an answer on June 5, 2026 at 11:11 pm

    You need to use java.util.Date exclusively in the model class and use java.sql.Date exclusively in the DAO class. In the view you should use <f:convertDateTime> to convert between the String representation in HTML/HTTP and the java.util.Date in the model class.

    Model:

    import java.util.Date;
    
    // ...
    
    private Date startDate;
    private Date endDate;
    

    View:

    <h:inputText value="#{customer.startDate}">
        <f:convertDateTime pattern="dd/MM/yyyy" />
    </h:inputText>
    <h:inputText value="#{customer.endDate}">
        <f:convertDateTime pattern="dd/MM/yyyy" />
    </h:inputText>
    

    DAO:

    import java.sql.Date;
    
    // ...
    
    preparedStatement.setDate(1, new Date(customer.getStartDate().getTime()));
    preparedStatement.setDate(2, new Date(customer.getEndDate().getTime()));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In a form I have one Date text field and 2 dropdowns: Start time
I am using a js calendar that inserts a string into a text field
I have two string variables such as StartTime and EndTime. I need to Calculate
I have a JAXB class like this: public class Game { private Date startTime;
I have two fields (StartTime and EndTime) both are varchar field (It was created
I have this recorded in SQL Server: 1- startTime (datetime): 5/2/2009 08:30 (brazilian time
I have two fields in my database for storing starttime and endtime. they are
I have two values coming in, a string in the form StartTime YYYY-MM-DD HH:MM:SS
I have certain sqlite data having the certain code. String sql = create table
I have ios application with datetimepicker, and i am store the date in to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.