package com.ruoyi.cai.util;

import java.time.LocalDate;

public class UserUtil {
    private final static int DEFAULT_AGE = 18;

    public static int getAge(LocalDate birthday){
        if(birthday == null){
            return DEFAULT_AGE;
        }
        int age = LocalDate.now().getYear() - birthday.getYear();
        if(age < 18 || age > 80){
            return DEFAULT_AGE;
        }
        return age;
    }
}
