if (newTextLength + characterCount < length) { characterCount += newTextLength; } else { characterCount = 0; }
characterCount = (newTextLength < length) ? newTextLength : 0;
void onVerify(Event event) {	if (ignoreVerify) return;	event.doit = false;	int fieldName = fieldNames[currentField];	int start = fieldIndices[currentField].x;	int end = fieldIndices[currentField].y;	int length = end - start;	String newText = event.text;	if (characterCount > 0) {		newText = "" + text.getSelectionText() + newText;	}	int newTextLength = newText.length();	if (newTextLength + characterCount < length) {		characterCount += newTextLength;	} else {		characterCount = 0;	}	try {		int max = calendar.getActualMaximum(fieldName);		int min = calendar.getActualMinimum(fieldName);		int newValue = Integer.parseInt(newText);		if (min <= newValue && newValue <= max) {			setTextField(fieldName, newValue, characterCount == 0);		} else {			if (newTextLength >= length) {				newValue = Integer.parseInt(newText.substring(newTextLength - length + 1));				if (min <= newValue && newValue <= max) {					setTextField(fieldName, newValue, characterCount == 0);				}			}		}	} catch (NumberFormatException ex) {	}}