Skip to content

Commit d931ba1

Browse files
committed
fixes the date range query in getNumItems() for Solr 9 by adding the time
1 parent 2c66da3 commit d931ba1

1 file changed

Lines changed: 7 additions & 6 deletions

File tree

dspace-api/src/main/java/org/dspace/app/statistics/LogAnalyser.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import java.sql.SQLException;
1717
import java.time.Instant;
1818
import java.time.LocalDate;
19+
import java.time.ZoneId;
1920
import java.time.format.DateTimeFormatter;
2021
import java.time.format.DateTimeParseException;
2122
import java.util.ArrayList;
@@ -1083,13 +1084,13 @@ public static LocalDate parseDate(String date) {
10831084

10841085

10851086
/**
1086-
* Take the date object and convert it into a string of the form YYYY-MM-DD
1087+
* Take the date object and convert it into an Instant datetime object of the form YYYY-MM-DDTHH:MM:SSZ
10871088
*
10881089
* @param date the date to be converted
1089-
* @return A string of the form YYYY-MM-DD
1090+
* @return An Instant datetime object of the form YYYY-MM-DDTHH:MM:SSZ
10901091
*/
1091-
public static String unParseDate(LocalDate date) {
1092-
return DateTimeFormatter.ISO_LOCAL_DATE.format(date);
1092+
public static Instant convertDate(LocalDate date) {
1093+
return date.atStartOfDay(ZoneId.systemDefault()).toInstant();
10931094
}
10941095

10951096

@@ -1219,13 +1220,13 @@ public static Integer getNumItems(Context context, String type)
12191220
StringBuilder accessionedQuery = new StringBuilder();
12201221
accessionedQuery.append("dc.date.accessioned_dt:[");
12211222
if (startDate != null) {
1222-
accessionedQuery.append(unParseDate(startDate));
1223+
accessionedQuery.append(convertDate(startDate));
12231224
} else {
12241225
accessionedQuery.append("*");
12251226
}
12261227
accessionedQuery.append(" TO ");
12271228
if (endDate != null) {
1228-
accessionedQuery.append(unParseDate(endDate));
1229+
accessionedQuery.append(convertDate(endDate));
12291230
} else {
12301231
accessionedQuery.append("*");
12311232
}

0 commit comments

Comments
 (0)