Browse - Programming Tips - How can I display the time with am/pm?

Date: 2014apr28
Language: Java
Level: Beginner

Q.  How can I display the time with am/pm?

A.

private static SimpleDateFormat fmtTime = new SimpleDateFormat("h:mma"); // h = hour without leading zero (because that's ugly) // mm = 2 digit minute // a = AM or PM (I make it lowercase since that looks nicer) String getTime() { Date date = new Date(); return fmtDate.format(date).toLowerCase(); }