List of usage examples for java.util Calendar AUGUST
int AUGUST
To view the source code for java.util Calendar AUGUST.
Click Source Link
From source file:org.celllife.idart.gui.patient.AddPatient.java
/** * checks if the given date is valid/*from www . jav a 2 s. c om*/ * * @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; }