is PM - Java java.util

Java examples for java.util:AM PM

Description

is PM

Demo Code


//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(isPM(date));
    }/*from   w  w w  . j a  v a 2s . com*/

    public static boolean isPM(final Date date) {
        return !isAM(date);
    }

    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;
    }
}

Related Tutorials