Parses a time grammer waiting on the character iterator. The grammer is
quite simple. It allows for us to specify quite precisely some unit of
time measure and convert it to a Java understandable form. It returns the
number of milliseconds that the unit of time represents.
For example, the string '2.5 hours' would return:
2.5 hours * 60 minutes * 60 seconds * 1000 milliseconds = 9000000
To construct a valid time measure, you must supply a sequence of time
measurements. The valid time measurements are 'week(s)', 'day(s)',
'hour(s)', 'minute(s)', 'second(s)', 'millisecond(s)'. To construct a
time, we simply concatinate the measurements together. For example,
'3 days 22 hours 9.5 minutes'
It accepts any number of time measurements, but not duplicates of the
same.
The time measures are case insensitive. It is a little lazy how it reads
the grammer. We could for example enter '1 hours 40 second' or even
more extreme, '1 houraboutit 90 secondilianit' both of which are
acceptable!
This method will keep on parsing the string until the end of the iterator
is reached or a non-numeric time measure is found. It throws a
ParseException if an invalid time measure is found or a number is invalid
(eg. -3 days).
LOCALE ISSUE: This will likely be a difficult method to localise.
|