I am trying to make a birthday verification program that checks if a person is underage or not, but I am having a hard time trying to get the values of the variables accessible to the Period.between().getYears() function.
private void txt_customerbdayKeyReleased(java.awt.event.KeyEvent evt) {
int month, day, year;
for(int x = 1; x<=txt_customerbday.getText().length(); x++){
if(txt_customerbday.getText().length() == 3){
month = Integer.parseInt(txt_customerbday.getText().substring(0,2));
System.out.print(month);
}
if(txt_customerbday.getText().length() == 6){
day = Integer.parseInt(txt_customerbday.getText().substring(3,5));
System.out.print(day);
}
if(txt_customerbday.getText().length() == 10){
year = Integer.parseInt(txt_customerbday.getText().substring(6,10));
System.out.print(year);
}
if(valBD(txt_customerbday.getText()) && txt_customerbday.getText().length() == 10){
lbl_bdaycheck.setForeground(Color.green);
lbl_bdaycheck.setText("Good Format");
}else{
lbl_bdaycheck.setForeground(Color.red);
lbl_bdaycheck.setText("Bad Format");
}
LocalDate today = LocalDate.now();
LocalDate birthdate = LocalDate.of(year, month, day);
Period.between(birthdate, today).getYears();
}
is there a way for me to get those values?
Aucun commentaire:
Enregistrer un commentaire