File tree Expand file tree Collapse file tree 1 file changed +6
-2
lines changed
src/main/java/com/saasquatch/jsonschemainferrer Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change 22
33import java .time .LocalDate ;
44import java .time .ZonedDateTime ;
5+ import java .util .regex .Pattern ;
56import javax .annotation .Nonnull ;
67import org .apache .commons .validator .routines .EmailValidator ;
78import org .apache .commons .validator .routines .InetAddressValidator ;
@@ -23,6 +24,10 @@ public String inferFormat(@Nonnull FormatInferrerInput input) {
2324 },
2425
2526 DATE_TIME {
27+
28+ private final Pattern timePattern = Pattern .compile (
29+ "^(?:[01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](?:\\ .\\ d+)?(?:Z|[+-](?:0[0-9]|2[0-3]):[0-5][0-9])$" );
30+
2631 @ Override
2732 public String inferFormat (@ Nonnull FormatInferrerInput input ) {
2833 final String textValue = input .getSample ().textValue ();
@@ -45,8 +50,7 @@ public String inferFormat(@Nonnull FormatInferrerInput input) {
4550 // Ignore
4651 }
4752 // The time format is not the same as Java's LocalTime and OffsetTime
48- if (textValue .matches (
49- "^(?:[01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](?:\\ .\\ d+)?(?:Z|[+-](?:0[0-9]|2[0-3]):[0-5][0-9])$" )) {
53+ if (timePattern .matcher (textValue ).matches ()) {
5054 return Consts .Formats .TIME ;
5155 }
5256 }
You can’t perform that action at this time.
0 commit comments