| parseTimer |
(String timerStr) |
yoix.util |
| |
Parses the
timerStr,
which is expected to match the pattern:
^\s*([0-9]+\s*[dD]\s*)?([0-9]+\s*[hH]\s*)?([0-9]+\s*[mM]\s*)?([0-9]+([.][0-9]*)?\s*[sS]\s*)?$
and returns
the corresponding number of seconds.
The letters d, h, m and s are meant to indicate days, hours, minutes and
seconds, respectively.
The numbers preceeding those letters are multiplied by an appropriate
factor (86400.0, 3600.0, 60.0 and 1.0, respectively) and the results are added
together to produce the returned result.
The format above is specified as a perl regular expression pattern
for the purposes of brevity in this documentation,
parseTimer
itself does not check
timeStr
against a pattern, but merely stops parsing when it cannot decode the string.
| |
| Example: |
A simple timer parsing example is:
import yoix.util.*;
import yoix.stdio.printf;
String elapsed = " 1 D 3h14M 3.2 s ";
printf("\"%s\" = %f\n", elapsed, parseTimer(elapsed));
yields:
" 1 D 3h14M 3.2 s " = 98043.200000
| | |
| Return: |
double
| | |
| See Also: |
currentTimeMillis,
date,
nanoTime,
parseDate,
sleep,
time,
timerFormat
|
|
Yoix is a registered trademark of AT&T Inc.
|