View Thread : To get Current Date and time in Java


achiever80
I want to display the current date and time on one of my form so how can i display the current date and time and which one function i have to call.
Plz help

urvisha
For getting current data and time im java you can use following code

public static String now(String dateFormat) {
Calendar cal = Calendar.getInstance();
SimpleDateFormat sdf = new SimpleDateFormat(dateFormat);
return sdf.format(cal.getTime());

}

and call this function like

System.out.println(DateUtils.now("dd MMMMM yyyy"));