SMILA 1.0 API documentation

org.eclipse.smila.utils.conversion
Class TimeSpanParser

java.lang.Object
  extended by org.eclipse.smila.utils.conversion.TimeSpanParser

public final class TimeSpanParser
extends java.lang.Object

Parses a time span. Currently the units supported are from seconds, minutes, hours and days.


Method Summary
static long parse(java.lang.String timeSpan, java.util.concurrent.TimeUnit timeUnit)
          Calls parse(String, TimeUnit, long) with default 0.
static long parse(java.lang.String timeSpan, java.util.concurrent.TimeUnit timeUnit, long defaultValue)
          Parses a time span string and returns the time span according to the given unit.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

parse

public static long parse(java.lang.String timeSpan,
                         java.util.concurrent.TimeUnit timeUnit,
                         long defaultValue)
Parses a time span string and returns the time span according to the given unit. If the given time span string is empty or null, the default value will be returned. Default time unit is seconds. Example time spans (which are all equal in value) are: Also mixed time spans can be used, but only in the correct order d, h, m, s e.g.: For each of the above strings the result of parsing it with the TimeUnit.MINUTES would result in the value of 1440. If the time span string could not be parsed or uses other suffixes than supported, an IllegalArgumentException will be thrown.

Parameters:
timeSpan - the string representing the time span
timeUnit - the TimeUnit to be used
defaultValue - the default value to use if the time span string was null or empty.
Returns:
the time span measured in the given TimeUnit.

parse

public static long parse(java.lang.String timeSpan,
                         java.util.concurrent.TimeUnit timeUnit)
Calls parse(String, TimeUnit, long) with default 0.


SMILA 1.0 API documentation