Java Date Formatting

Add AM PM to time using SimpleDateFormat

Want to learn quickly?
Try one of the many quizzes. More than Java 400 questions with detailed answers.

3 Comments

  • you used HH, what if it was in the afternoon at 1pm? the result would be
    13:00:00 PM

    you shouldve used K or h

  • I want to display the AM/PM past as single character as a/p.

    In the given example the time is 01:39:42 AM but I want to show it as 01:39:42 A.

    I tried both HH:mm:ss a and HH:mm:ss aaa but the results are same.

Sponsors

Facebook Fans