How to print out the current Date and Time?

Question:
How can I print out the current date and time?

Answer:
By using the SimpleDateFormat class.

Code:
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
 
 
public class CurrentDate {
 
   public static void main(String[] args) {
 
      Date date = new Date();
      DateFormat df = new SimpleDateFormat("E MM-dd-yyyy hh:mm:ss aa");
 
      System.out.println(df.format(date));
 
   }
}

Output:
$ java CurrentDate 
Sun 02-16-2014 03:29:40 PM