|
|
@@ -396,13 +396,13 @@ public class CalendarUtil {
|
|
|
* @return 年龄
|
|
|
*/
|
|
|
protected static int age(long birthday, long dateToCompare) {
|
|
|
- Calendar cal = Calendar.getInstance();
|
|
|
- cal.setTimeInMillis(dateToCompare);
|
|
|
-
|
|
|
- if (cal.before(birthday)) {
|
|
|
+ if (birthday > dateToCompare) {
|
|
|
throw new IllegalArgumentException("Birthday is after dateToCompare!");
|
|
|
}
|
|
|
|
|
|
+ final Calendar cal = Calendar.getInstance();
|
|
|
+ cal.setTimeInMillis(dateToCompare);
|
|
|
+
|
|
|
final int year = cal.get(Calendar.YEAR);
|
|
|
final int month = cal.get(Calendar.MONTH);
|
|
|
final int dayOfMonth = cal.get(Calendar.DAY_OF_MONTH);
|