Java
public static void main(String[] args) throws ParseException {
System.out.println("输入你的生日yyyy-MM-dd");
Scanner sc =new Scanner(System.in);
String str = sc.nextLine();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Date birth =sdf.parse(str);
long birthMs = birth.getTime();//得到生日毫秒数
// long now = new Date().getTime();//获取当前毫秒数
long now = System.currentTimeMillis();
long dates = (now-birthMs)/24/3600/1000;
System.out.println("你活了"+dates+"天");
}