Displaying Current Date and Time in JSP
843838Apr 9 2007 — edited Feb 21 2008Hi,
I need to insert the current date time in Ms SQL Server Database using jsp page. The format of the code willbe
insert into table(update_date) values ('2007-01-01 10:02:21');
But i am not getting how to display the current date and time ie. 2007-01-01 10:02:21 using jsp.
I have tried using
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
GregorianCalendar cal = new GregorianCalendar();
String dd = sdf.format(cal.getTime());
insert into table(update_date) values (dd);
But it didnot get inserted data.
Can anybody figure out with simple ideas.
Thank You