Date Complete time and date format(%tc)
import java.util.Calendar;
import java.util.Formatter;
public class MainClass {
public static void main(String args[]) {
Formatter fmt = new Formatter();
Calendar cal = Calendar.getInstance();
fmt = new Formatter();
fmt.format("%tc", cal);
System.out.println(fmt);
}
}
Output:
Wed Jun 11 10:39:58 PDT 2008
Home
Java Book
Runnable examples
Java Book
Runnable examples
Formatter:
- Date Complete time and date format(%tc)
- Date hour and minute format(%tl:%tM)
- Date Month name and number format(%tB %tb %tm)
- Date Standard 12-hour time format(%tr)