Java tutorial
import java.util.Calendar; import java.util.Formatter; public class MainClass { public static void main(String args[]) { Formatter fmt = new Formatter(); // Display standard 12-hour time format. fmt.format("%tr", Calendar.getInstance()); System.out.println(fmt); } }