Im trying to calculate a users age based on their DOB input and compare it with todays date to work out their age in years. If they are under 12 they will be denied.
int YearDiff;
public void ageCalc()
{
ZoneId nowBrit = ZoneId.of("Europe/London");
LocalDate timeBrit = LocalDate.now(nowBrit);
SimpleDateFormat sdf = new SimpleDateFormat("yyyy");
int YearNow = Integer.parseInt(sdf.format(timeBrit));
int YearSel = Integer.parseInt(sdf.format(jDateChooserDOB.getDate()));
YearDiff = YearNow - YearSel;
}
The YearDiff variable will then be tested to see if its less than 12 in an if statement however it always returns 0.
Also if there is a better way to do age verification please do share.
Thanks in advance