I need to validate three dates that are of type JDateChooser
.
These dates are: date of birth, date of admission and date of dismissal.
The date of birth can not be greater than the date of admission and no more than the date of dismissal.
The date of dismissal can not be less than the date of admission.
I want to validate the date of admission at the time the user pops up, an alert window will be fired if that date is less than the date of birth. And the same happens between the date of admission and the date of dismissal.
I have tried to do this validation with an if - else, but only works for two cases at once, or just for one. And I used the event mouseEntered
and set a minimum value for the dates. But I have this error
Exception in thread "AWT-EventQueue-0" java.lang.IllegalArgumentException
. Would anyone have a suggestion? Thank you.
Attempt 1
if(dataAdm().getDate().after(dataNasc.getDate())){
if(dataDem().getDate().after(DataAdm.getDate())){
mensagem de alerta;
}
}
Attempt with the propertyChange event and mouseClicked event in the date field.
if(dataAdm().getDate().after(dataNasc.getDate())){
mensagem de alerta;
}
Screen Print
actionPerformed
validacao=newValidaSuper();if(validacao.recebeDadosObrigatorios(nome.getText(),cpf.getText(),orgaoExp.getText(),funcao.getText(),email.getText())){if(validacao.validaDadosObrigatorios()){if(dataAdm.getDate().after(dataNasc.getDate())){if(dataDem.getDate().after(dataAdm.getDate())){setDadosObrigatorios();setDados();idCoord=map.insereCoordenador(coord);map.insereTelefoneCoordenador(tel,idCoord);JOptionPane.showMessageDialog(this,"Coordenador(a) inserido(a) com sucesso !!!");
limparCampos();
}
}
}
}
}catch (UnsupportedEncodingException ex) {
Logger.getLogger(CadastraCoordenador.class.getName()).log(Level.SEVERE, null, ex);
}catch (SQLException ex) {
Logger.getLogger(CadastraCoordenador.class.getName()).log(Level.SEVERE, null, ex);
}