Code example for GregorianCalendar

Methods: beforeget

    public static GregorianCalendar getValidatedBirthdate(final int year, final int monthOfYear, 
    		final int dayOfMonth) {
    	GregorianCalendar currentDate = new GregorianCalendar();
    	GregorianCalendar preferredDate = new GregorianCalendar(year, monthOfYear, dayOfMonth);
    	GregorianCalendar oldestDate = new GregorianCalendar(MINIMUM_BIRTH_DATE, JANUARY, 
    	if (preferredDate.before(oldestDate)) { // is the birthdate before 1916 (android.DateUtils) 
    		// or 1900 (android.widget.DatePicker)? platform limitation! 
    		// return the oldest possible year (1916) with the month and the date entered by the user 
    		oldestDate.set(Calendar.YEAR, MINIMUM_BIRTH_DATE);
    		oldestDate.set(Calendar.MONTH, preferredDate.get(Calendar.MONTH));
    		oldestDate.set(Calendar.DAY_OF_MONTH, preferredDate.get(Calendar.DAY_OF_MONTH));
    		return oldestDate;
    	} else if (currentDate.before(preferredDate)) { // is the birthdate entered in the future?
    		// enter the current date 
    		return currentDate;