Skip to content

Commit

Permalink
SCTP-432: Relaxing matching pattern for date/time string (#41)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mahesh Subramanian committed Oct 14, 2019
1 parent ba6ac36 commit b8b3df7
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ on [Keep a CHANGELOG](http://keepachangelog.com/). This project adheres to
[Semantic Versioning](http://semver.org/).

## [Unreleased]
### Fixed
- Date time pattern to accommodate for missing seconds entry

## [6.1.1] - 2019-10-09
### Fixed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public class StringPattern {
public static final Pattern UUID_PATTERN = compile("^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$");
public static final Pattern DATE_PATTERN = compile("^((([\\+-]?\\d{4}(?!\\d{2}\\b))\\-(0[13578]|1[02])\\-(0[1-9]|[12]\\d|3[01]))|(([\\+-]?\\d{4}(?!\\d{2}\\b))\\-(0[13456789]|1[012])\\-(0[1-9]|[12]\\d|30))|(([\\+-]?\\d{4}(?!\\d{2}\\b))\\-02\\-(0[1-9]|1\\d|2[0-8]))|(((1[6-9]|[2-9]\\d)(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00))\\-02\\-29))$");
public static final Pattern EMAIL_PATTERN = compile("^[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?\\.)+[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$");
public static final Pattern DATE_TIME_PATTERN = compile("^(-?(?:[1-9][0-9]*)?[0-9]{4})-(1[0-2]|0[1-9])-(3[01]|0[1-9]|[12][0-9])(T|\\s)(2[0-3]|[01][0-9]):([0-5][0-9]):([0-5][0-9])(.[0-9]+)?(Z)?$");
public static final Pattern DATE_TIME_PATTERN = compile("^(-?(?:[1-9][0-9]*)?[0-9]{4})-(1[0-2]|0[1-9])-(3[01]|0[1-9]|[12][0-9])(T|\\s)(2[0-3]|[01][0-9]):([0-5][0-9])(:([0-5][0-9])(.[0-9]+)?)?(Z)?$");
public static final Pattern NI_NUMBER_PATTERN = compile("(?!BG)(?!GB)(?!NK)(?!KN)(?!TN)(?!NT)(?!ZZ)(?:[A-CEGHJ-PR-TW-Z][A-CEGHJ-NPR-TW-Z])(?:\\s*\\d\\s*){6}([A-D]|\\s)$");
public static final Pattern POSTCODE_PATTERN = compile("^(([gG][iI][rR] {0,}0[aA]{2})|(([aA][sS][cC][nN]|[sS][tT][hH][lL]|[tT][dD][cC][uU]|[bB][bB][nN][dD]|[bB][iI][qQ][qQ]|[fF][iI][qQ][qQ]|[pP][cC][rR][nN]|[sS][iI][qQ][qQ]|[iT][kK][cC][aA]) {0,}1[zZ]{2})|((([a-pr-uwyzA-PR-UWYZ][a-hk-yxA-HK-XY]?[0-9][0-9]?)|(([a-pr-uwyzA-PR-UWYZ][0-9][a-hjkstuwA-HJKSTUW])|([a-pr-uwyzA-PR-UWYZ][a-hk-yA-HK-Y][0-9][abehmnprv-yABEHMNPRV-Y]))) {0,}[0-9][abd-hjlnp-uw-zABD-HJLNP-UW-Z]{2}))$");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ public void shouldReturnDateTimeStringGenerator() {
assertThat(factory.getGenerator("2016-11-16 11:22:58.319Z"), instanceOf(DateTimeGenerator.class));
assertThat(factory.getGenerator("2016-11-16 11:22:58Z"), instanceOf(DateTimeGenerator.class));
assertThat(factory.getGenerator("2016-11-16 11:22:58"), instanceOf(DateTimeGenerator.class));
assertThat(factory.getGenerator("2016-11-16T11:22"), instanceOf(DateTimeGenerator.class));
assertThat(factory.getGenerator("2016-11-16 11:22"), instanceOf(DateTimeGenerator.class));
}

@Test
Expand Down

0 comments on commit b8b3df7

Please sign in to comment.