Java Language Finding AM/PM


Example

With Calendar class it is easy to find AM or PM.

  Calendar cal = Calendar.getInstance();
  cal.setTime(new Date());
  if (cal.get(Calendar.AM_PM) == Calendar.PM)
      System.out.println("It is PM");