Example usage for java.util Calendar MAY

List of usage examples for java.util Calendar MAY

Introduction

In this page you can find the example usage for java.util Calendar MAY.

Prototype

int MAY

To view the source code for java.util Calendar MAY.

Click Source Link

Document

Value of the #MONTH field indicating the fifth month of the year in the Gregorian and Julian calendars.

Usage

From source file:com.icesoft.faces.component.selectinputdate.SelectInputDateRenderer.java

/**
 * @param symbols//from  w  ww. j  a va  2  s . c  o m
 * @return months - String[] containing localized month names
 */
public static String[] mapMonths(DateFormatSymbols symbols) {
    String[] months = new String[12];

    String[] localeMonths = symbols.getMonths();

    months[0] = localeMonths[Calendar.JANUARY];
    months[1] = localeMonths[Calendar.FEBRUARY];
    months[2] = localeMonths[Calendar.MARCH];
    months[3] = localeMonths[Calendar.APRIL];
    months[4] = localeMonths[Calendar.MAY];
    months[5] = localeMonths[Calendar.JUNE];
    months[6] = localeMonths[Calendar.JULY];
    months[7] = localeMonths[Calendar.AUGUST];
    months[8] = localeMonths[Calendar.SEPTEMBER];
    months[9] = localeMonths[Calendar.OCTOBER];
    months[10] = localeMonths[Calendar.NOVEMBER];
    months[11] = localeMonths[Calendar.DECEMBER];

    return months;
}

From source file:org.celllife.idart.gui.patient.AddPatient.java

/**
 * checks if the given date is valid//from  w w w  . j av a 2 s  .  co  m
 * 
 * @param strDay
 *            String
 * @param strMonth
 *            String
 * @param strYear
 *            String
 * @return true if the date is valid else false
 */
public boolean dateOkay(String strDay, String strMonth, String strYear) {

    boolean result = false;

    try {

        int day = Integer.parseInt(strDay);

        // check the year
        if (strYear.length() != 4)
            return result;
        int year = Integer.parseInt(strYear);

        // get the int value for the string month (e.g. January)
        // int month = Integer.parseInt(strMonth);
        int month = -1;
        for (int i = 0; i < cmbDOBMonth.getItemCount(); i++) {
            if (strMonth.equals(cmbDOBMonth.getItem(i))) {
                month = i;
            }
        }

        switch (month) {
        case -1:
            result = false;
            break;
        case Calendar.FEBRUARY:
            if (day <= 29) {
                GregorianCalendar greg = new GregorianCalendar();
                if (day == 29 & greg.isLeapYear(year)) {
                    result = true;
                } else {
                    if (day == 29) {
                        result = false;
                    } else {
                        result = true;
                    }
                }
            } else {
                result = false;
            }
            break;
        case Calendar.JANUARY | Calendar.MARCH | Calendar.MAY | Calendar.JULY | Calendar.AUGUST
                | Calendar.OCTOBER | Calendar.DECEMBER:
            if (day <= 31) {
                result = true;
            } else {
                result = false;
            }
            break;
        default:
            result = true;
            break;
        }
    } catch (RuntimeException e) {
        e.printStackTrace();
    }

    return result;

}