Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Displaying Current Date and Time in JSP

843838Apr 9 2007 — edited Feb 21 2008
Hi,
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
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 20 2008
Added on Apr 9 2007
8 comments
2,533 views