Java examples for java.util:AM PM
is AM
//package com.java2s; import java.util.Calendar; import java.util.Date; import java.util.GregorianCalendar; import static java.util.Calendar.AM_PM; public class Main { public static void main(String[] argv) throws Exception { Date date = new Date(); System.out.println(isAM(date)); }//from w ww. j a va2 s . co m public static boolean isAM(final Date date) { return fromDateToCalendar(date).get(AM_PM) == 0; } public static Calendar fromDateToCalendar(final Date date) { final Calendar cal = new GregorianCalendar(); cal.clear(); cal.setMinimalDaysInFirstWeek(4); cal.setFirstDayOfWeek(Calendar.MONDAY); cal.setTime(date); return cal; } }