mirror of
https://gitee.com/dromara/hutool.git
synced 2025-04-24 18:04:54 +08:00
fix code
This commit is contained in:
parent
1463172c2d
commit
3a1eb66f14
@ -18,11 +18,13 @@ import org.dromara.hutool.core.date.DateTime;
|
||||
import org.dromara.hutool.core.date.DateUtil;
|
||||
import org.dromara.hutool.core.date.TimeUtil;
|
||||
import org.dromara.hutool.core.date.Zodiac;
|
||||
import org.dromara.hutool.core.lang.Console;
|
||||
import org.dromara.hutool.core.text.StrUtil;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.Objects;
|
||||
|
||||
|
||||
/**
|
||||
@ -404,24 +406,20 @@ public class ChineseDate {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return getChineseDay().hashCode() ^ getChineseMonth().hashCode()
|
||||
^ Integer.valueOf(getChineseYear()).hashCode();
|
||||
public boolean equals(final Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
final ChineseDate that = (ChineseDate) o;
|
||||
return year == that.year && month == that.month && day == that.day;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (obj instanceof ChineseDate) {
|
||||
ChineseDate other = (ChineseDate) obj;
|
||||
return day == other.day
|
||||
&& month == other.month
|
||||
&& year == other.year
|
||||
&& isLeapMonth == other.isLeapMonth;
|
||||
}
|
||||
return false;
|
||||
public int hashCode() {
|
||||
return Objects.hash(year, month, day);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------- private method start
|
||||
|
@ -17,6 +17,7 @@ import org.dromara.hutool.core.text.StrUtil;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.Date;
|
||||
import java.util.Objects;
|
||||
|
||||
@ -178,13 +179,13 @@ public class ChineseDateTest {
|
||||
@Test
|
||||
public void equalsTest(){
|
||||
// 二月初一
|
||||
Date date1 = new Date(2023 - 1900, 1, 20);
|
||||
final Date date1 = DateUtil.date(LocalDate.of(2023, 2, 20));
|
||||
// 润二月初一
|
||||
Date date2 = new Date(2023 - 1900, 2, 22);
|
||||
final Date date2 = DateUtil.date(LocalDate.of(2023, 3, 22));
|
||||
|
||||
ChineseDate chineseDate1 = new ChineseDate(date1);
|
||||
ChineseDate chineseDate2 = new ChineseDate(date2);
|
||||
ChineseDate chineseDate3 = new ChineseDate(date2);
|
||||
final ChineseDate chineseDate1 = new ChineseDate(date1);
|
||||
final ChineseDate chineseDate2 = new ChineseDate(date2);
|
||||
final ChineseDate chineseDate3 = new ChineseDate(date2);
|
||||
|
||||
Assertions.assertEquals("2023-02-01", chineseDate1.toStringNormal());
|
||||
Assertions.assertEquals("2023-02-01", chineseDate2.toStringNormal());
|
||||
|
Loading…
Reference in New Issue
Block a user