Skip to content

Commit

Permalink
Allow more fractions in the ISO date
Browse files Browse the repository at this point in the history
  • Loading branch information
musketyr committed May 2, 2022
1 parent 59dbda0 commit e667dc2
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public class MatchesPattern extends BaseMatcher<String> {
/**
* Matches ISO Date.
*/
public static final Matcher<String> ISO_DATE = matchesPattern("\\d{4}-[01]\\d-[0-3]\\dT[0-2]\\d:[0-5]\\d(:[0-5]\\d(\\.\\d{1,3})?)?([+-][0-2]\\d:[0-5]\\d|Z)");
public static final Matcher<String> ISO_DATE = matchesPattern("\\d{4}-[01]\\d-[0-3]\\dT[0-2]\\d:[0-5]\\d(:[0-5]\\d(\\.\\d{1,10})?)?([+-][0-2]\\d:[0-5]\\d|Z)");

/**
* Matches any positive number integer string.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ class MatchesIsoDateNowSpec extends Specification {
where:
matches | date
true | new DateTime().toString(ISODateTimeFormat.dateTime())
true | new DateTime().toString(ISODateTimeFormat.dateHourMinuteSecondFraction()) + 'Z'
true | new DateTime().toString(ISODateTimeFormat.dateTimeNoMillis())
true | new DateTime().toString(ISODateTimeFormat.dateTimeNoMillis())
true | Instant.now().toString()
false | 'foo.bar'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ class MatchesPatternSpec extends Specification {
matches | date
true | new DateTime().toString(ISODateTimeFormat.dateTime())
true | new DateTime().toString(ISODateTimeFormat.dateTimeNoMillis())
true | new DateTime().toString(ISODateTimeFormat.dateHourMinuteSecondFraction()) + 'Z'
true | '2022-05-02T06:59:08.502028Z'
false | 'foo.bar'
false | null

Expand Down

0 comments on commit e667dc2

Please sign in to comment.