我只使用
java.time.LocalDate
public class RandomDate {
private final LocalDate today;
private final Random random;
private final int months;
public RandomDate(Random random, int months) {
this.random = random;
}
public LocalDate getRangeEndDate() {
LocalDate rangeEndDay = day.hs * 30);
return rangeEndDay;
}
public LocalDate generateRandomDate(LocalDate endDate) {
int start = (int) EpochDay();
int end = (int) EpochDay();
long randomDay = start + Int(end - start);
return LocalDate.ofEpochDay(randomDay);
}
public LocalDate getToday() {
return today;
}
public Random getRandom() {
return random;
}
public int getMonths() {
return months;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof RandomDate)) return false;
RandomDate that = (RandomDate) o;
return getMonths() == Months() &&
Objects.equals(getToday(), Today()) &&
Objects.equals(getRandom(), Random());
}
@Override
public int hashCode() {
return Objects.hash(getToday(), getRandom(), getMonths());
}
@Override
public String toString() {
return "RandomDate{" +
"today=" + today +
", random=" + random +
", months=" + months +
'}';
}}
本文发布于:2024-02-05 05:20:25,感谢您对本站的认可!
本文链接:https://www.4u4v.net/it/170725077063390.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
留言与评论(共有 0 条评论) |