/**
* Returns the Current Date and Time in String Format
*/
public static String returnDateAndTime() {
Date d = new Date();
String Nowdate = DateFormat.getDateTimeInstance().format(d);
return Nowdate;
}
/**
* Translates any long value to its respective date and time
*/
public static String returnDateAndTime(long currentTime) {
return DateFormatUtils.format(currentTime, "dd-MMM-yyyy HH:mm:ss");
}
u also need to import the following packages
import java.util.*; //for manipulating the time
import java.text.*;
import org.apache.commons.lang.time.*; // formatting numbers