Beto
Beto

Reputation: 5

JSP Date to PostgreSQL Date JasperException

This is the second week trying to find an answer to my problem... everything fine works except when inserting a date field to database problem... I am sure someone can help me! THANK YOU !

Database column is: campstart and it is a "Timestamp without time zone"

++++++++++ JSP page with the following:

... (some code) // Formatting the date:

SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy HH:mm");

... (some code) // getting input from webpage

<input name="start" type="text" value="<%= defaultCampaign.getCampstart() != null ? dateFormat.format(defaultCampaign.getCampstart()) : dateFormat.format(new java.util.Date()) %>">

... (more code)

++++++++++ On Java:

... (some code) // declaring variable

private java.util.Date campstart = null;

... (some code) // assigning data

public void setCampstart(java.util.Date aCampstart) {   
this.campstart = aCampstart;  } 

public java.util.Date getCampstart() {
  return this.campstart; }

... (some code) // writing to PostgreSQL +below is the line with problems+

pst.setTimestamp(10, new Timestamp(this.getCampstart().getTime()));

... (more code)

+++++++++

It works fine when I change the code line to the following (for debugging):

pst.setTimestamp(10, new Timestamp(new java.util.Date().getTime()));

The date Insert works perfectly, it writes to Database without errors. But, when I change the code to insert the user date, it gives me the following error:

org.apache.jasper.JasperException: Unable to convert string "04/07/2012 19:12" to class "java.util.Date" for attribute "campstart": Property Editor not registered with the PropertyEditorManager

Can someone please help me to figure out what I am doing wrong...

THANK YOU !!

Rob.

Upvotes: 0

Views: 1010

Answers (1)

Beto
Beto

Reputation: 5

Got it to work when I changed the format on the date. For some reason it was sending it on the month like "7" instead of "07".

Upvotes: 0

Related Questions