mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
fix leepYear bug
This commit is contained in:
@@ -1,11 +1,10 @@
|
||||
package cn.hutool.core.date;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import cn.hutool.core.date.BetweenFormater.Level;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import cn.hutool.core.date.BetweenFormater.Level;
|
||||
import java.util.Date;
|
||||
|
||||
public class DateBetweenTest {
|
||||
|
||||
@@ -28,6 +27,14 @@ public class DateBetweenTest {
|
||||
Assert.assertEquals(0, betweenYear2);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void betweenYearTest2() {
|
||||
Date start = DateUtil.parse("2000-02-29");
|
||||
Date end = DateUtil.parse("2018-02-28");
|
||||
long betweenYear = new DateBetween(start, end).betweenYear(false);
|
||||
Assert.assertEquals(18, betweenYear);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void betweenMonthTest() {
|
||||
Date start = DateUtil.parse("2017-02-01 12:23:46");
|
||||
|
@@ -616,4 +616,12 @@ public class DateUtilTest {
|
||||
DateTime date = DateUtil.date(localDateTime);
|
||||
Assert.assertEquals("2017-05-06 08:30:00", date.toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void ageTest(){
|
||||
String d1 = "2000-02-29";
|
||||
String d2 = "2018-02-28";
|
||||
final int age = DateUtil.age(DateUtil.parseDate(d1), DateUtil.parseDate(d2));
|
||||
Assert.assertEquals(18, age);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user