per convertire un campo di un form da stringa a data ho fato il seguente codice :
*******
String tmp=inserimentoNotiziaForm.getDataNotizia();
SimpleDateFormat data = new SimpleDateFormat("dd/MM/yyyy");
Date datan = data.parse(tmp);
*****
però mi da il sugeunte errore:
"InserimentoNotiziaAction.java": Error #: 360 : unreported exception: java.text.ParseException; must be caught or declared to be thrown at line 35, column 19
come devo fare per cacciare ?
il codice completo è:
****
public class InserimentoNotiziaAction extends Action{
public ActionForward perform(ActionMapping mapping, ActionForm form, HttpServletRequest richiesta, HttpServletResponse response) throws IOException, ServletException {
ActionErrors errors = new ActionErrors();
System.out.println("InserimentoNotiziaAction");
try {
InserimentoNotiziaForm inserimentoNotiziaForm = (InserimentoNotiziaForm) form;
//java.util.Date dataNotizia=new java.util.Date(inserimentoNotiziaForm.getDataNotiz ia());
String tmp=inserimentoNotiziaForm.getDataNotizia();
SimpleDateFormat data = new SimpleDateFormat("dd/MM/yyyy");
Date datan = data.parse(tmp);
System.out.println("prova insertnot :" +datan);
Notizie notizia= NotizieDBManager.inserimentoNotizie(inserimentoNot iziaForm.getIdNotizia(),datan,inserimentoNotiziaFo rm.getSommario(),inserimentoNotiziaForm.getTesto() ,inserimentoNotiziaForm.getId());
return mapping.findForward("inserimentonotizia");
}
catch(ErroreAccessoDatiException e){
// abbiamo avuto un problema di accesso dati!
errors.add("error",new ActionError("Attenzione! A causa di un errore interno non e' stato possibile verificare le tue credenziali d'accesso."));
}
catch(SQLException e) {
errors.add("error",new ActionError("Attenzione! A causa di un errore interno non e' stato possibile verificare le tue credenziali d'accesso2."));
}
super.saveErrors(richiesta, errors);
return mapping.findForward("errore");
}
******