Skip to content

Commit

Permalink
119687: Solr date sort field format check fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Atmire-Kristof committed Oct 30, 2024
1 parent c35d7a6 commit 56becc6
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions dspace-api/src/main/java/org/dspace/sort/OrderFormatDate.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ public class OrderFormatDate implements OrderFormatDelegate {

@Override
public String makeSortString(String value, String language) {
if (!isValidDate(value)) {
return null;
}

int padding = 0;
int endYearIdx = value.indexOf('-');

Expand All @@ -30,18 +34,13 @@ public String makeSortString(String value, String language) {
padding = 4 - value.length();
}

String newValue = value;
if (padding > 0) {
// padding the value from left with 0 so that 87 -> 0087, 687-11-24
// -> 0687-11-24
newValue = String.format("%1$0" + padding + "d", 0)
return String.format("%1$0" + padding + "d", 0)
+ value;
}

if (isValidDate(newValue)) {
return newValue;
} else {
return null;
return value;
}
}

Expand Down

0 comments on commit 56becc6

Please sign in to comment.