java - The String source is unknown while using the parse methode! -
to parse string date sql valid:
simpledateformat df = new simpledateformat("yyyy-mm-dd"); java.util.date date = null; try { date = df.parse(dateimput); } catch (parseexception e2) { // todo auto-generated catch block e2.printstacktrace(); }
with dateimput form that: string dateimput=request.getparameter("datepicker");
when running see error:
java.text.parseexception: format.parseobject(string) failed @ java.text.format.parseobject(unknown source) @ servletedition.dopost(servletedition.java:70)
so mean dateimput not known + note correctly dislayed when:
system.out.println("datepicker:" +dateimput);
thanks.
so seems first time complicated see solution. in fact need 2 simple date formater because tha parsing in case done in 2 steps:
system.out.println("datepicker:" +dateimput); simpledateformat df1 = new simpledateformat("mm/dd/yyyy"); simpledateformat df2=new simpledateformat("yyyy-mm-dd"); date dt=null; try { dt = df1.parse(dateimput); system.out.println("dt" +dt); system.out.println("dt formatted" +df2.format(dt)); } catch (parseexception e1) { // todo auto-generated catch block e1.printstacktrace(); }
it works fine , ok
Comments
Post a Comment