Skip to content

Commit

Permalink
Add date format and respective test case (#9310)
Browse files Browse the repository at this point in the history
* Added date format and respective test case

* add test for negative values as well
fix checkstyle

* checkstyle

Co-authored-by: Siedlerchr <siedlerkiller@gmail.com>
  • Loading branch information
yanyanliu1400 and Siedlerchr authored Nov 7, 2022
1 parent b767ed2 commit 2b38019
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/main/java/org/jabref/model/entry/Date.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@ public class Date {
"d.M.uuuu", // covers 15.1.2015
"uuuu.M.d", // covers 2015.1.15
"uuuu", // covers 2015
"MMM, uuuu"); // covers Jan, 2020
"MMM, uuuu", // covers Jan, 2020
"uuuu/M", // covers 2020/10
"uuuu.MM.d" // covers 2015.10.15
);

SIMPLE_DATE_FORMATS = formatStrings.stream()
.map(DateTimeFormatter::ofPattern)
Expand Down
5 changes: 4 additions & 1 deletion src/test/java/org/jabref/model/entry/DateTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,10 @@ private static Stream<Arguments> validDates() {
Arguments.of(LocalDate.of(2015, Month.JANUARY, 15), "15.1.2015"),
Arguments.of(LocalDate.of(2015, Month.JANUARY, 15), "2015.1.15"),
Arguments.of(Year.of(2015), "2015"),
Arguments.of(YearMonth.of(2020, Month.JANUARY), "Jan, 2020"));
Arguments.of(YearMonth.of(2020, Month.JANUARY), "Jan, 2020"),
Arguments.of(LocalDate.of(2015, Month.OCTOBER, 15), "2015.10.15"),
Arguments.of(LocalDate.of(-10000, Month.OCTOBER, 15), "-10000-10-15")
);
}

@ParameterizedTest
Expand Down

0 comments on commit 2b38019

Please sign in to comment.