Click Here To Get Amazing Facebook Profile Covers,Status Messages

How to get current date and time and display it in particular format

1 reply [Last post]
angel's picture
angel
User offline. Last seen 2 years 39 weeks ago. Offline
Joined: 08/22/2009

I want to display current date and time in my JSP page and in addition to that i want to know how to display date and time in specified format.


rajesh's picture
rajesh
User offline. Last seen 12 weeks 6 days ago. Offline
Joined: 08/17/2009
current date display in dd-MMM-yyyy hh:mm:ss format

java.util.Date dt=new java.util.Date();//for current date
DateFormat df = new SimpleDateFormat("dd-MMM-yyyy hh:mm:ss");//dateformatter
String myformattedDate = df.format(dt);
out.println(myformattedDate);