Java Utililty Methods Regex Time Validate

List of utility methods to do Regex Time Validate

Description

The list of methods to do Regex Time Validate are organized into topic(s).

Method

longparseTimestamp(String s)
parse Timestamp
s = s.toLowerCase();
long ms = 0;
Matcher matcher = TIMESTAMP_PATTERN.matcher(s);
while (matcher.find()) {
    String numStr = matcher.group(1);
    String unitStr = matcher.group(2);
    TimeUnit unit;
    if (unitStr == null) {
...
longparseTimeString(String str)
parse Time String
AtomicLong millis = new AtomicLong(0);
long seconds = 0;
long minutes = 0;
long hours = 0;
Matcher m = TIMESTAMP_PATTERN.matcher(str);
m.find();
int capturedGroups = 0;
if (m.group(1) != null)
...
longparseTimeString(String str, TimeUnit unit)
Convert a passed time string (e.g.
String lower = str.toLowerCase().trim();
try {
    Matcher m = Pattern.compile("(-?[0-9]+)([a-z]+)?").matcher(lower);
    if (!m.matches()) {
        throw new NumberFormatException("Failed to parse time string: " + str);
    long val = Long.parseLong(m.group(1));
    String suffix = m.group(2);
...
longparseTimeString(String time)
Parses the given time String and returns the corresponding time in milliseconds
String trimmed = time.trim();
long result = 0;
if (trimmed.length() > 0) {
    Matcher mat = SIMPLE.matcher(trimmed);
    if (mat.matches()) {
        int days = (mat.group(SIM_DAY) != null) ? Integer.parseInt(mat.group(SIM_DAY)) : 0;
        int hours = (mat.group(SIM_HOU) != null) ? Integer.parseInt(mat.group(SIM_HOU)) : 0;
        int min = (mat.group(SIM_MIN) != null) ? Integer.parseInt(mat.group(SIM_MIN)) : 0;
...