Date Standard 12-hour time format(%tr)
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.format("%tr", cal);
System.out.println(fmt);
}
}
Output:
10:39:33 AM
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)