RED-7694 - Backport Fix invalid date period

This commit is contained in:
Andrei Isvoran 2023-10-04 11:37:31 +02:00
parent fe84f2ef04
commit 9e5bd8cfef
2 changed files with 7 additions and 2 deletions

View File

@ -36,10 +36,15 @@ public class LicenseReportRequest {
return startDate;
}
public boolean isStartDateBeforeEndDate() {
var endDate = this.endDate == null ? Instant.now() : this.endDate;
return getStartDate().isBefore(endDate);
}
public Instant getEndDate() {
if (endDate == null) {
if (endDate == null || endDate.isAfter(Instant.now())) {
endDate = Instant.now();
}
return endDate;

View File

@ -36,7 +36,7 @@ public class LicenseReportService {
public LicenseReport getLicenseReport(LicenseReportRequest licenseReportRequest) {
if (licenseReportRequest.getEndDate().isBefore(licenseReportRequest.getStartDate())) {
if (!licenseReportRequest.isStartDateBeforeEndDate()) {
throw new BadRequestException("Invalid date period: End date is before start date.");
}