I'm trying to check if a user is older than 13 years. So I did the following.
public boolean isUserOldEnough(String birthDay) {
Date date = null;
try {
date = new SimpleDateFormat("YYYY/MM/DD").parse(birthDay);
} catch (ParseException e) {
e.printStackTrace();
}
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
long birthTime = calendar.getTimeInMillis();
return birthTime > getMinAge();
}
public long getMinAge() {
Calendar calendar = Calendar.getInstance();
int currentYear = calendar.get(Calendar.YEAR);
calendar.set(currentYear - 13, Calendar.MONTH, Calendar.DAY_OF_MONTH);
return calendar.getTimeInMillis();
}
From the first method, with 2000/01/21
, I get 946159200000
, while the second method gives 1110033481894
, how do I get the correct time from the first method?
1 : 946159200000
2 : 1110033481894
Something is wrong with the first method and I can't get it right.