mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-04-19 03:01:48 +08:00
fix code:三月初一与闰二月初一不应该相等
This commit is contained in:
parent
0ac5b56180
commit
6ed1661c3d
@ -414,12 +414,12 @@ public class ChineseDate {
|
||||
return false;
|
||||
}
|
||||
final ChineseDate that = (ChineseDate) o;
|
||||
return year == that.year && month == that.month && day == that.day;
|
||||
return year == that.year && month == that.month && day == that.day && isLeapMonth == that.isLeapMonth;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(year, month, day);
|
||||
return Objects.hash(year, month, day, isLeapMonth);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------- private method start
|
||||
|
@ -182,16 +182,22 @@ public class ChineseDateTest {
|
||||
final Date date1 = DateUtil.date(LocalDate.of(2023, 2, 20));
|
||||
// 润二月初一
|
||||
final Date date2 = DateUtil.date(LocalDate.of(2023, 3, 22));
|
||||
// 三月初一
|
||||
final Date date4 = DateUtil.date(LocalDate.of(2023, 4, 20));
|
||||
|
||||
|
||||
final ChineseDate chineseDate1 = new ChineseDate(date1);
|
||||
final ChineseDate chineseDate2 = new ChineseDate(date2);
|
||||
final ChineseDate chineseDate3 = new ChineseDate(date2);
|
||||
final ChineseDate chineseDate4 = new ChineseDate(date4);
|
||||
|
||||
Assertions.assertEquals("2023-02-01", chineseDate1.toStringNormal());
|
||||
Assertions.assertEquals("2023-02-01", chineseDate2.toStringNormal());
|
||||
Assertions.assertEquals("2023-02-01", chineseDate3.toStringNormal());
|
||||
Assertions.assertEquals("2023-03-01", chineseDate4.toStringNormal());
|
||||
|
||||
Assertions.assertNotEquals(chineseDate1, chineseDate2);
|
||||
Assertions.assertEquals(chineseDate2, chineseDate3);
|
||||
Assertions.assertNotEquals(chineseDate2, chineseDate4);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user