mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-04-19 03:01:48 +08:00
fix test
This commit is contained in:
parent
4a574e3241
commit
660b64daf6
@ -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);
|
||||
|
@ -700,8 +700,7 @@ public class DateUtilTest {
|
||||
public void ageTest2(){
|
||||
String d1 = "2019-02-29";
|
||||
String d2 = "2018-02-28";
|
||||
final int age = DateUtil.age(DateUtil.parseDate(d1), DateUtil.parseDate(d2));
|
||||
Assert.assertEquals(18, age);
|
||||
DateUtil.age(DateUtil.parseDate(d1), DateUtil.parseDate(d2));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
Loading…
x
Reference in New Issue
Block a user