File tree Expand file tree Collapse file tree 2 files changed +10
-4
lines changed
main/java/org/everit/json/schema/internal
test/java/org/everit/json/schema/internal Expand file tree Collapse file tree 2 files changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -30,14 +30,20 @@ public class DateTimeFormatValidator implements FormatValidator {
30
30
31
31
private static final String DATETIME_FORMAT_STRING_SECFRAC = "yyyy-MM-dd'T'HH:mm:ss.SSSXXX" ;
32
32
33
+ private SimpleDateFormat dateFormat (final String pattern ) {
34
+ SimpleDateFormat rval = new SimpleDateFormat (pattern );
35
+ rval .setLenient (false );
36
+ return rval ;
37
+ }
38
+
33
39
@ Override
34
40
public Optional <String > validate (final String subject ) {
35
41
try {
36
- new SimpleDateFormat (DATETIME_FORMAT_STRING ).parse (subject );
42
+ dateFormat (DATETIME_FORMAT_STRING ).parse (subject );
37
43
return Optional .empty ();
38
44
} catch (ParseException e ) {
39
45
try {
40
- new SimpleDateFormat (DATETIME_FORMAT_STRING_SECFRAC ).parse (subject );
46
+ dateFormat (DATETIME_FORMAT_STRING_SECFRAC ).parse (subject );
41
47
return Optional .empty ();
42
48
} catch (ParseException e1 ) {
43
49
return Optional .of (String .format ("[%s] is not a valid date-time" , subject ));
Original file line number Diff line number Diff line change @@ -49,7 +49,7 @@ public void dateTimeFormatFailure() {
49
49
50
50
@ Test
51
51
public void dateTimeSecFracSuccess () {
52
- assertSuccess ("2015-02-30T11 :00:00.111Z" , new DateTimeFormatValidator ());
52
+ assertSuccess ("2015-02-28T11 :00:00.111Z" , new DateTimeFormatValidator ());
53
53
}
54
54
55
55
@ Test
@@ -59,7 +59,7 @@ public void dateTimeSuccess() {
59
59
60
60
@ Test
61
61
public void dateTimeZSuccess () {
62
- assertSuccess ("2015-02-30T11 :00:00Z" , new DateTimeFormatValidator ());
62
+ assertSuccess ("2015-02-28T11 :00:00Z" , new DateTimeFormatValidator ());
63
63
}
64
64
65
65
@ Test
You can’t perform that action at this time.
0 commit comments