Question: I am getting this error: 

> 
> java.lang.IllegalArgumentException: Timestamp format must be yyyy-mm-dd 
>  hh:mm:ss[.fffffffff] 
> 
> 
> 

Here is my java code:

```
<%  int reg;

        String sdate = request.getParameter("sdate");
        //Timestamp ts=request.get
      //out.println(sdate);
         String text = "0000-00-00 00:00:00";
       Timestamp ts = Timestamp.valueOf(text);
       // Timestamp ts1=Timestamp.valueOf(sdate);
       //  Timestamp ts2=Timestamp.valueOf(edate);
    try{
          String s;
      Format formatter;
     Date date = new Date(sdate);
     //out.println(date);
      formatter = new SimpleDateFormat("yyyy:MM:dd HH:mm:ss");
     s = formatter.format(date);
     out.println(s);
        PreparedStatement ps=cn.prepareStatement("insert into c1 values(?)");
                           // ps.setString(1,ts);
         ps.setTimestamp(1,ts);

                            int i=ps.executeUpdate();
                            if(i==1)
                        {
                       pw.println("record inserted");
                        }
                        else
                        {
                        pw.println("not iNSERTED");
                        }
                        //cn.close();

                       }
                 catch(Exception e)
                        {
                            out.println(e.toString());
                        }

    %>

```

Any Suggestions?

Answer: 
This

```
String text = "0000-00-00 00:00:00";

```

is not a valid date. There is no month or day with a value of `0`.

The `Timestamp.valueOf(text)` will not be able to parse it.

At least use

```
String text = "0000-01-01 00:00:00";

```
i use the jdbc's native timestamp type: 

```
Date date = myobject.getDate();

cstmt = conn.prepareCall("{call dbo.myproc(?)}");
cstmt.setTimestamp("date", new Timestamp(date.getTime())
cstmt.execute();

```