com.twitter.common.args.parsers
Class DurationParser

java.lang.Object
  extended by com.twitter.common.args.parsers.TypeParameterizedParser<Amount>
      extended by com.twitter.common.args.parsers.DurationParser

public class DurationParser
extends TypeParameterizedParser<Amount>

Utility class for parsing durations of the form "1d23h59m59s" (as well as subvariants, i.e. "10h5s" would also work, as would "2d"). These values are useful representations in HTTP query parameters for durations.


Constructor Summary
DurationParser()
           
 
Method Summary
static Amount<Long,Time> parse(String spec)
          Parses a duration of the form "1d23h59m59s" (as well as subvariants, i.e.
 
Methods inherited from class com.twitter.common.args.parsers.TypeParameterizedParser
parse
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DurationParser

public DurationParser()
Method Detail

parse

public static Amount<Long,Time> parse(String spec)
Parses a duration of the form "1d23h59m59s" (as well as subvariants, i.e. "10h5s" would also work, as would "2d").

Parameters:
spec - the textual duration specification
Returns:
the parsed form
Throws:
IllegalArgumentException - if the specification can not be parsed