}
+ /**
+ * @param date
+ * YYYYMMDD
+ */
+ public static boolean isDateValid(String date) {
+ int year = Integer.parseInt(date.substring(0, 4));
+ int month = Integer.parseInt(date.substring(4, 6));
+ int day = Integer.parseInt(date.substring(6, 8));
+ return isDateValid(year, month, day);
+ }
+
public static boolean isOfAge(DayDate dob, int age) {
+ return isYearsInFuture(dob.start(), age);
+ }
+
+ public static boolean isYearsInFuture(Date dt, int age) {
Calendar c = Calendar.getInstance();
- c.setTimeInMillis(dob.getTime());
- int year = c.get(Calendar.YEAR);
- int month = c.get(Calendar.MONTH);
- int day = c.get(Calendar.DAY_OF_MONTH);
- c.set(year, month, day);
+ c.setTime(dt);
c.add(Calendar.YEAR, age);
return System.currentTimeMillis() >= c.getTime().getTime();