Finding AMPM

suggest change

With the Calendar class it is easy to find AM or PM. Calendar.AM is 0 and Calendar.PM is 1. getInstance() is already the current time, so setTime(new Date()) does not change the instant.

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

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents