Calcular edad java

public int calcularEdad(Calendar fechaNac){
    Calendar today = Calendar.getInstance();
    int diff_year = today.get(Calendar.YEAR) - fechaNac.get(Calendar.YEAR);
    int diff_month = today.get(Calendar.MONTH) - fechaNac.get(Calendar.MONTH);
    int diff_day = today.get(Calendar.DAY_OF_MONTH) - fechaNac.get(Calendar.DAY_OF_MONTH);
    //Si está en ese año pero todavía no los ha cumplido
    if(diff_month<0 || (diff_month==0 && diff_day<0)){
        diff_year = diff_year - 1; //no aparecían los dos guiones del postincremento :|
    }
    return diff_year;
}

HTML Character Entities




Mas info en:
http://www.w3schools.com/html/html_entities.asp 

Validación: Solo números con dos decimales

<SCRIPT LANGUAGE="JavaScript"> function NumCheck(e, field) { key = e.keyCode ? e.keyCode : e.which // backspace if (key == 8) return true // 0-9 if (key > 47 && key < 58) { if (field.value == "") return true regexp = /.[0-9]{2}$/ return !(regexp.test(field.value)) } // . if (key == 46) { if (field.value == "") return false regexp = /^[0-9]+$/ return regexp.test(field.value) } // other key return false } </script> <input type="text" onkeypress="return NumCheck(event, this)"/>