Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ public static Interval fromString(String s) {
if (s == null) {
return null;
}
s = s.trim();
Matcher m = p.matcher(s);
if (!m.matches() || s.equals("interval")) {
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,12 @@ public void fromStringTest() {
Interval result = new Interval(-5 * 12 + 23, 0);
assertEquals(Interval.fromString(input), result);

input = "interval -5 years 23 month ";
assertEquals(Interval.fromString(input), result);

input = " interval -5 years 23 month ";
assertEquals(Interval.fromString(input), result);

// Error cases
input = "interval 3month 1 hour";
assertEquals(Interval.fromString(input), null);
Expand Down