Skip to content

Commit

Permalink
Merge pull request #156 from networknt/fix/#155-date-time-validation
Browse files Browse the repository at this point in the history
Fix 24-hour validation error
  • Loading branch information
stevehu authored May 30, 2019
2 parents 93a698b + 4829f9d commit d75550c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/main/java/com/networknt/schema/DateTimeValidator.java
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ private boolean isLegalDateTime(String string) {
minute = matcher.group(6);
second = matcher.group(7);
dateTime.append('T').append(hour).append(':').append(minute).append(':').append(second);
pattern.append("'T'hh:mm:ss");
pattern.append("'T'HH:mm:ss");
if (matcher.group(8) != null) {
// Normalize milliseconds to 3-length digit
milliseconds = matcher.group(8);
Expand Down
19 changes: 17 additions & 2 deletions src/test/resources/tests/optional/format.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,21 @@
"data": "1963-06-19T08:30:06.283185Z",
"valid": true
},
{
"description": "a valid date-time string",
"data": "2019-07-24T00:00:01-04:00",
"valid": true
},
{
"description": "an invalid date-time string",
"data": "2019-07-24T24:00:01-04:00",
"valid": false
},
{
"description": "an invalid date-time string",
"data": "2019-07-24T25/:00:01-04:00",
"valid": false
},
{
"description": "an invalid date-time string",
"data": "06/19/1963 08:30:06 PST",
Expand Down Expand Up @@ -59,9 +74,9 @@
"valid": false
},
{
"description": "an invalid date-time string",
"description": "a valid date-time string",
"data": "2019-02-28T13:30:06Z",
"valid": false
"valid": true
},
{
"description": "an invalid date-time string",
Expand Down

0 comments on commit d75550c

Please sign in to comment.