dsto.dfc.text
Class DurationConverter

java.lang.Object
  extended by dsto.dfc.text.DurationConverter
All Implemented Interfaces:
IStringTranslator

public class DurationConverter
extends Object
implements IStringTranslator

Converts time durations between string form and seconds form (eg between "2 minutes" and 120).

Version:
$Revision$
Author:
mpp

Nested Class Summary
 
Nested classes/interfaces inherited from interface dsto.dfc.text.IStringTranslator
IStringTranslator.FromString, IStringTranslator.ToString
 
Field Summary
static DurationConverter INSTANCE
          Singleton instance: useful if using as a ITranslator.
 
Method Summary
static String convert(int durationSecs)
           
static int convert(String durationExpr)
           
 Object fromString(String string)
          Convert/parse a string into the object type supported by this converter.
 String toString(Object value)
          Convert a value to a string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

INSTANCE

public static final DurationConverter INSTANCE
Singleton instance: useful if using as a ITranslator.

Method Detail

fromString

public Object fromString(String string)
                  throws InvalidFormatException
Description copied from interface: IStringTranslator
Convert/parse a string into the object type supported by this converter.

Specified by:
fromString in interface IStringTranslator
Parameters:
string - The string to convert.
Returns:
The converted object.
Throws:
InvalidFormatException - if the string is not in a format parsable by the converter.

toString

public String toString(Object value)
                throws IllegalArgumentException
Description copied from interface: IStringTranslator
Convert a value to a string.

Specified by:
toString in interface IStringTranslator
Parameters:
value - The value to convert. Null is not guaranteed to be valid.
Returns:
The string equivalent.
Throws:
IllegalArgumentException - if value is an object type understood by the converter.

convert

public static int convert(String durationExpr)
                   throws InvalidFormatException
Throws:
InvalidFormatException

convert

public static String convert(int durationSecs)


Copyright © 2008 Commonwealth of Australia