date problem worng date inserted into database

hi all,

I m writing simple program which has one jsp having one textfiled and a submit button. The textfiled takes date value and after submission value goes to servlet where i m inserting this date value into database using stored procedure. (actully this is kind of requirement in a project)

program is working fine but after insertion when i see the inserted date then it is entering worng dates.

like i tried 12-06-2006 then it insert 12-02-2006

i tried 04-11-2005 then it inserted 04-02-2006

means it is everytime taking feb month.

for Database i m using sqlserver 2000

The codes are

<%@ page language="java"%>

<html>

<body>

<form action ="/attentencedate/test" method=get>

<input type="text" name="txtdate" >

<input type=submit value="submit" name="submit">

</form>

</body>

</html>

import com.sanatprinters.utilities.*;

import com.sanatprinters.dispatcher.*;

import javax.servlet.*;

import javax.servlet.http.*;

import java.io.*;

import javax.naming.*;

import javax.sql.*;

import java.sql.*;

import java.text.*;

import java.util.Date;

public class test extends HttpServlet

{

private Connection conn;

private PreparedStatement pstmt;

private ResultSet rs;

String Query=null;

private CallableStatement cstmt;

public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException

{

PrintWriter out=response.getWriter();

response.setContentType("text/html");

sanatDataSource _sds=null;

try

{

_sds= new sanatDataSource();

conn=_sds.openConnection();

System.out.println("this is e");

Query="{call myproc(?)}";

cstmt=conn.prepareCall(Query);

//pstmt=conn.prepareStatement(Query);

System.out.println("this hi");

String datestring=request.getParameter("txtdate");

SimpleDateFormat sdf=new SimpleDateFormat("dd-mm-yyyy");

Date date=sdf.parse(datestring);

cstmt.setDate(1,new java.sql.Date(date.getTime()));

cstmt.execute();

}

catch(Exception e)

{

System.out.println("Employee Exception : " + e);

}

}

}

CREATE PROCEDURE myproc

@txtdate datetime AS

insert into attendate(empdate) values(@txtdate);

GO

[2519 byte] By [cooljassia] at [2007-11-27 5:59:07]
# 1
Re-read the [url= http://java.sun.com/j2se/1.5.0/docs/api/java/text/SimpleDateFormat.html]SimpleDateFormat API[/url] how to convert to Month.
BalusCa at 2007-7-12 16:35:08 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 2
Use "dd-MM-yyyy" instead. Please submit shorter code blocks that have only the relevant code.
mamgeorgea at 2007-7-12 16:35:08 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...