Skip to content

Commit

Permalink
Little bit of cleanup in DateTime.parseDateTimeString() by removing
Browse files Browse the repository at this point in the history
a regex that isn't used and formatting the variable names per TSD
spec.

Signed-off-by: Chris Larsen <[email protected]>
  • Loading branch information
manolama committed Oct 8, 2016
1 parent 24ed995 commit 3091079
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/utils/DateTime.java
Original file line number Diff line number Diff line change
Expand Up @@ -121,15 +121,14 @@ public static final long parseDateTimeString(final String datetime,
} else {
try {
long time;
Boolean containsDot = datetime.contains(".");
final boolean contains_dot = datetime.contains(".");
// [0-9]{10} ten digits
// \\. a dot
// [0-9]{1,3} one to three digits
Boolean isValidDottedMillesecond = datetime.matches("^[0-9]{10}\\.[0-9]{1,3}$");
// one to ten digits (0-9)
Boolean isValidSeconds = datetime.matches("^[0-9]{1,10}$");
if (containsDot) {
if (!isValidDottedMillesecond) {
final boolean valid_dotted_ms =
datetime.matches("^[0-9]{10}\\.[0-9]{1,3}$");
if (contains_dot) {
if (!valid_dotted_ms) {
throw new IllegalArgumentException("Invalid time: " + datetime
+ ". Millisecond timestamps must be in the format "
+ "<seconds>.<ms> where the milliseconds are limited to 3 digits");
Expand Down

0 comments on commit 3091079

Please sign in to comment.